springMVC.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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 使用前缀和后缀 -->
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 使用组件扫描的方式可以一次扫描多个Controller -->
<context:component-scan base-package="com.wxisme.ssm.controller">
</context:component-scan>
<!-- 配置注解的处理器映射器和处理器适配器 -->
<mvc:annotation-driven conversion-service="conversionService"></mvc:annotation-driven>
<!-- 自定义参数类型绑定 -->
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="converters">
<list>
<!-- 日期类型绑定 -->
<bean class="com.wxisme.ssm.controller.converter.DateConverter"/>
</list>
</property>
</bean>
<!-- 访问静态资源文件 -->
<!-- <mvc:default-servlet-handler/> 需要在web.xml中配置-->
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/js/**" location="/js/" />
<mvc:resources mapping="/imgdata/**" location="/imgdata/" />
<!-- 定义拦截器 -->
<mvc:interceptors>
<!-- 直接定义拦截所有请求 -->
<bean class="com.wxisme.ssm.interceptor.IdentityInterceptor"></bean>
<!-- <mvc:interceptor>
拦截所有路径的请求 包括子路径
<mvc:mapping path="/**"/>
<bean class="com.wxisme.ssm.interceptor.IdentityInterceptor"></bean>
</mvc:interceptor> -->
</mvc:interceptors>
<!--配置上传文件数据解析器 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize">
<value>9242880</value>
</property>
</bean>
<!-- 定义全局异常处理器 -->
<!-- 只有一个全局异常处理器起作用 -->
<bean id="exceptionResolver" class="com.wxisme.ssm.exception.OverallExceptionResolver"></bean>
</beans>