1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:mvc="http://www.springframework.org/schema/mvc"
5 xmlns:context="http://www.springframework.org/schema/context"
6 xmlns:aop="http://www.springframework.org/schema/aop"
7 xmlns:tx="http://www.springframework.org/schema/tx"
8 xsi:schemaLocation="
9 http://www.springframework.org/schema/beans
10 https://www.springframework.org/schema/beans/spring-beans.xsd
11 http://www.springframework.org/schema/mvc
12 https://www.springframework.org/schema/mvc/spring-mvc.xsd
13 http://www.springframework.org/schema/context
14 https://www.springframework.org/schema/context/spring-context.xsd
15 http://www.springframework.org/schema/aop
16 http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
17 http://www.springframework.org/schema/tx
18 http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
19
20 <!-- 开启注解扫描,只扫描controller注解-->
21 <context:component-scan base-package="com.lu">
22 <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
23 </context:component-scan>
24 <!-- 配置的视图解析器-->
25 <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
26 <property name="prefix" value="/WEB-INF/pages/"></property>
27 <property name="suffix" value=".jsp"></property>
28 </bean>
29 <!--过滤静态资源-->
30 <mvc:resources mapping="/css/**" location="/css/"></mvc:resources>
31 <mvc:resources mapping="/images/**" location="/images/"></mvc:resources>
32 <mvc:resources mapping="/js/**" location="/js/"></mvc:resources>
33 <!-- 开启springmvc注解的支持-->
34 <mvc:annotation-driven>
35 <mvc:message-converters>
36 <!--json编码设置-->
37 <!--第一种消息转换器spring自带的,fastjson和jackson共有-->
38 <bean class="org.springframework.http.converter.StringHttpMessageConverter">
39 <property name="supportedMediaTypes">
40 <list>
41 <value>application/json;charset=UTF-8</value>
42 </list>
43 </property>
44 </bean>
45 <!--第二种消息转换器fastjson独有的,自动将ajax的返回参数转换为json格式,控制器可直接return对象-->
46 <!-- <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
47 <property name="supportedMediaTypes">
48 <list>
49 <value>test/html;charset=UTF-8</value>
50 <value>application/json</value>
51 </list>
52 </property>
53 </bean>-->
54 </mvc:message-converters>
55 </mvc:annotation-driven>
56 <mvc:default-servlet-handler/>
57
58 <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
59 <property name="maxUploadSize" value="10240000"></property>
60 </bean>
61 </beans>