spring-mvc.xml
3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?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/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
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 扫面那个包 -->
<context:component-scan base-package="com.sibu.orderHelper.integralMall.controller.*" />
<!-- 启用扫描 -->
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="com.sibu.orderHelper.common.converter.UTF8StringHttpMessageConverter" />
<!-- 配置Fastjson 替换原来的jackson支持 -->
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json</value>
</list>
</property>
<property name="features">
<list>
<value>QuoteFieldNames</value> <!-- 输出key时是否使用双引号,默认为true -->
<value>WriteMapNullValue</value> <!-- 是否输出值为null的字段,默认为false -->
<value>DisableCircularReferenceDetect</value>
<!--
<value>WriteDateUseDateFormat</value>
<value>WriteNullStringAsEmpty</value> 字符类型字段如果为null,输出为"",而非null
<value>WriteNullNumberAsZero</value> 数值字段如果为null,输出为0,而非null
<value>WriteNullBooleanAsFalse</value> Boolean字段如果为null,输出为false,而非null
<value>WriteNullListAsEmpty</value> List字段如果为null,输出为[],而非null
-->
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:default-servlet-handler/>
<!-- 将静态文件指定到某个特殊的文件夹中统一处理 -->
<mvc:resources location="/resources/" mapping="/resources/**" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/page/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 全局异常处理 -->
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="com.sibu.orderHelper.Exception.NullException">error</prop>
</props>
</property>
</bean>
<!-- 设置multipartResolver才能完成文件上传,文件上传 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="5000000"></property>
</bean>
</beans>