spring-mvc相关配置
文件名一般为:spring-mvc.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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">
<!-- 组件扫描-->
<context:component-scan base-package="com.ren.controller"/>
<!-- 配置mvc注解驱动-->
<mvc:annotation-driven/>
<!-- 开放静态资源访问权限-->
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/imgs/**" location="/imgs/"/>
<!--开放静态资源方式或者是-->
<mvc:default-servlet-handler/>
<!-- 内部资源视图解析器-->
<bean id="internalResourceViewResolver " class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!-- 文件上传解析器-->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 设置文件上传总大小-->
<property name="maxUploadSize" value="100000000"/>
<!--设置单个文件大小 -->
<property name="maxUploadSizePerFile" value="10000"/>
<!-- 处理中文乱码 -->
<property name="defaultEncoding" value="UTF-8"/>
<!--启用推迟文件解析,以便捕获文件大小异常 -->
<property name="resolveLazily" value="true"/>
</bean>
</beans>