springmvc的核心过滤器dispatcherservlet有加载配置文件的作用吗

发布网友

我来回答

2个回答

懂视网

dispatcherservlet的作用是:

  

  1、文件上传解析,如果请求类型是multipart将通过MultipartResolver进行文件上传解析;

  

  2、通过HandlerMapping,将请求映射到处理器;

  

  3、通过HandlerAdapter支持多种类型的处理器;

  

  4、通过ViewResolver解析逻辑视图名到具体视图实现;

  

  5、本地化解析;

  

  6、渲染具体的视图等;

  

  7、如果执行过程中遇到异常将交给HandlerExceptionResolver来解析。

  

  

热心网友

springmvc的核心过滤器dispatcherservlet有加载配置文件的作用
配置文件名为:project.properties,内容如下:

# 是否开启逻辑删除
del.filter.on=false
domain

修改Spring配置文件
之前代码:

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:dbinfo.properties</value>
</list>
</property>
</bean>

修改后的配置文件

<bean id="propertyConfigurer"
class="com.hisun.core.util.CustomizedPropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:dbinfo.properties</value>
<value>classpath:project.properties</value>
</list>
</property>
</bean>

加入了classpath:project.properties,其为自定义的配置文件
将PropertyPlaceholderConfigurer类修改为自定义类CustomizedPropertyPlaceholderConfigurer,
PropertyPlaceholderConfigurer类的具体作用可以查资料这块儿不做详细介绍
定义CustomizedPropertyPlaceholderConfigurer类
类的具体内容为下,

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class CustomizedPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
private static Map ctxPropertiesMap;

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com