<?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:aop="http://www.springframework.org/schema/aop"
|
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
|
<!-- 自动扫描且只扫描@Controller -->
|
<context:component-scan base-package="com.da.controller" use-default-filters="false">
|
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
|
</context:component-scan>
|
|
<mvc:annotation-driven>
|
<mvc:message-converters register-defaults="true">
|
<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
|
<property name="supportedMediaTypes" value="text/html;charset=UTF-8" />
|
</bean>
|
</mvc:message-converters>
|
</mvc:annotation-driven>
|
<aop:aspectj-autoproxy/>
|
<!-- 将无法mapping到Controller的path交给default servlet handler处理 -->
|
<!--<mvc:default-servlet-handler/>-->
|
<mvc:resources mapping="/static/**" location="/static/"/>
|
|
<!-- 定义JSP文件的位置 -->
|
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
<property name="prefix" value="/WEB-INF/"/>
|
<property name="suffix" value=".jsp"/>
|
</bean>
|
|
<!-- 上传file-->
|
<bean id="multipartResolver"
|
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
<!--resolveLazily属性启用是为了推迟文件解析,以便在UploadAction 中捕获文件大小异常-->
|
<property name="resolveLazily" value="true"/>
|
<!-- one of the properties available; the maximum file size in bytes -->
|
<property name="maxUploadSize">
|
<!-- 最大2M -->
|
<value>3000000</value>
|
<!-- 设置上传文件大小 -1 为不限制大小 -->
|
</property>
|
<!-- <property name="maxInMemorySize">
|
<value>128</value>
|
上传时的最大占用内存 128
|
</property> -->
|
<property name="defaultEncoding">
|
<value>UTF-8</value>
|
<!-- 设置上传时的编码 -->
|
</property>
|
</bean>
|
|
</beans>
|