[XML] 纯文本查看 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/s ... ing-context-4.0.xsd">
<!-- 配置组件扫描controller -->
<context:component-scan base-package="cn.itheima.ssm.controller"/>
<!-- 注解驱动方式配置处理器映射器,处理器适配器 -->
<mvc:annotation-driven conversion-service="conversionService"></mvc:annotation-driven>
<!-- 配置转换服务 -->
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="converters">
<set>
<bean class="cn.itheima.ssm.converter.DateConverter"/>
</set>
</property>
</bean>
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 配置视图的公共目录路径 -->
<property name="prefix" value="/WEB-INF/jsp/"></property>
<!-- 配置视图的扩展名称 -->
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 配置异常处理器 -->
<bean class="cn.itheima.ssm.exception.SsmExceptionResolver"/>
<!-- 配置文件上传解析器 ,说明:
1.文件上传解析器的id属性值,必须是文件上传解析器接口的名称,首字母小写(MultipartResolver)-->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- Provides "maxUploadSize", "maxInMemorySize" and "defaultEncoding"
settings as bean properties -->
<!-- maxUploadSize属性:上传文件大小限制,以字节为单位:
10M=10*1024*1024 -->
<property name="maxUploadSize" value="10485760"></property>
<!-- maxInMemorySize属性:配置内存缓存区大小,以字节为单位:
4k=4*1024-->
<property name="maxInMemorySize" value="4096"></property>
<!-- 配置字符集编码 -->
<property name="defaultEncoding" value="UTF-8"></property>
</bean>
<!-- 配置拦截器 -->
<mvc:interceptors>
<!-- 配置拦截器一 -->
<mvc:interceptor>
<!-- 配置拦截的url,说明:
1.拦截单个url:/interceptor.do,表示拦截单个请求:/interceptor.do
2.拦截多个url:/inter/**,表示拦截以/inter开头的所有请求-->
<mvc:mapping path="/interceptor.do"/>
<!-- 指定谁来拦截 -->
<bean class="cn.itheima.ssm.interceptor.FirstInterceptor"/>
</mvc:interceptor>
<!-- 配置拦截器二 -->
<mvc:interceptor>
<mvc:mapping path="/interceptor.do"/>
<bean class="cn.itheima.ssm.interceptor.SecondInterceptor"/>
</mvc:interceptor>
<!-- 配置登录拦截器 -->
<mvc:interceptor>
<mvc:mapping path="/queryItem.do"/>
<bean class="cn.itheima.ssm.interceptor.LoginInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
</beans>