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"
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">
(一) 视图解析器
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
<context:component-scan base-package="com.itheima"/>
(二) SpringMVC注解驱动
<mvc:annotation-driven/>
(二) 解决SpringMVC项目静态资源无法访问
<mvc:default-servlet-handler/>
(三) 请求参数类型转换器
<bean id="stringToDateConverter" class="com.itheima.utils.StringToDateConverter"/>
<bean id="conversionFactory" class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<set>
<ref bean="stringToDateConverter"/>
</set>
</property>
</bean>
<mvc:annotation-driven conversion-service="conversionFactory"/>
(四) springmvc的文件上传解析器CommonsMultipartResolver
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="10485760"/>
</bean>
(五) SpringMvc自定义异常处理类 实现HandlerExceptionResolver接口
<bean id="自定义的异常处理类" class="com.itheima.utils.MyExceptionHandler"/>
(六) SpringMVC自定义拦截器类 实现HandlerInterceptor接口
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/findAll"/>
<bean class="com.itheima.utils.Demo1Intercepter"/>
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.itheima.utils.Demo2Intercepter"/>
</mvc:interceptor>
</mvc:interceptors>
</beans>