<?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 https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--声明注解的包扫描器-->
<context:component-scan base-package="com.fsx.controller"/>
<!--声明视图解析器-->
<bean id="resourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!--注解驱动,处理映射器和适配器-->
<mvc:annotation-driven conversion-service="myDate"/>
<!--声明时间格式转换器-->
<bean id="myDate" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="converters">
<set>
<bean class="com.fsx.utils.DateConvert"/>
</set>
</property>
</bean>
<!--声明多媒体解析器,id值必须为multipartResolver-->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 设置最大上传文件的大小8M -->
<property name="maxUploadSize" value="8388608"/>
<!--设置单个文件的大小-->
<property name="maxUploadSizePerFile" value="1000000"/>
<!--设置字符编码-->
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<!--处理静态资源一-->
<mvc:resources mapping="/static/**" location="/static/"/>
<!--处理静态资源二,交给tomcat-->
<!--<mvc:default-servlet-handler/>-->
<!--声明全局异常处理器-->
<bean id="myException" class="com.fsx.exception.MyException"/>
<!--注册拦截器-->
<mvc:interceptors>
<mvc:interceptor>
<!--设置全部拦截-->
<mvc:mapping path="/**"/>
<!--设置不需要拦截-->
<mvc:exclude-mapping path="/user/**"/>
<!--创建拦截器对象-->
<bean class="com.fsx.interceptors.MyInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
</beans>
SSM整合springmvc.xml
最新推荐文章于 2022-09-01 23:48:09 发布