spring-mvc.xml
3.8 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
80
81
82
<?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-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<mvc:default-servlet-handler/>
<!-- 启用扫描 -->
<mvc:annotation-driven>
<!-- <mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json;charset=UTF-8" />
</bean>
</mvc:message-converters> -->
<mvc:message-converters>
<bean class="com.sibu.orderHelper.common.converter.UTF8StringHttpMessageConverter" />
</mvc:message-converters>
<!-- <mvc:argument-resolvers>
<bean class="com.sibu.common.web.bind.CurrentUserMethodArgumentResolver"/>
</mvc:argument-resolvers> -->
</mvc:annotation-driven>
<context:component-scan base-package="com.sibu.orderHelper.service.log.aspect" />
<aop:aspectj-autoproxy proxy-target-class="true"/>
<!-- 扫面那个包 -->
<context:component-scan base-package="com.sibu.orderHelper.integralWeb.controller" />
<!-- 定义JSON转换器 -->
<bean
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
<value>application/xml;charset=utf-8</value>
<value>application/x-www-form-urlencoded; charset=UTF-8</value>
</list>
</property>
<property name="objectMapper">
<bean class="com.sibu.orderHelper.common.util.JacksonObjectMapper" />
</property>
</bean>
<!-- 将静态文件指定到某个特殊的文件夹中统一处理 -->
<mvc:resources location="/resources/" mapping="/resources/**" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<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>
<property name="statusCodes">
<props>
<prop key="com.sibu.orderHelper.Exception.ApiDataException">500</prop>
<prop key="com.sibu.orderHelper.Exception.ApiDataException">404</prop>
</props>
</property>
<!-- 设置日志输出级别,不定义则默认不输出警告等错误日志信息 -->
<property name="warnLogCategory" value="WARN"></property>
<!-- 默认错误页面,当找不到上面mappings中指定的异常对应视图时,使用本默认配置 -->
<property name="defaultErrorView" value="errors/error"></property>
<!-- 默认HTTP状态码 -->
<property name="defaultStatusCode" value="500"></property>
</bean>
<!-- 设置multipartResolver才能完成文件上传,文件上传 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="5000000"></property>
</bean>
</beans>