spring-mvc.xml
6.5 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?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"
xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util"
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-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/websocket http://www.springframework.org/schema/websocket/spring-websocket-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<!--配置springmvc -->
<!--1:开始SpringMVC注解模式 -->
<context:annotation-config />
<!-- 自动扫描且只扫描@Controller -->
<context:component-scan
base-package="com.w1hd.zzhnc.*.controller;org.theyeasy.weixin.controller;org.theyeasy.weixin.util;"
use-default-filters="false">
</context:component-scan>
<context:component-scan base-package="com.w1hd.zzhnc.config" />
<util:properties id="wxProperties" location="classpath:wx.open.properties" />
<util:properties id="wxPayProperties" location="classpath:wx.pay.properties" />
<context:component-scan base-package="org.theyeasy.weixin.model"></context:component-scan>
<context:component-scan base-package="org.theyeasy.weixin.service"></context:component-scan>
<context:component-scan base-package="org.theyeasy.weixin.handler"></context:component-scan>
<mvc:resources mapping="/swagger/**" location="/WEB-INF/swagger-ui/" />
<mvc:view-controller path="/" view-name="/index" />
<!-- swagger 配置 -->
<bean name="swaggerConfig"
class="com.w1hd.zzhnc.config.ApplicationSwaggerConfig" />
<mvc:annotation-driven
content-negotiation-manager="contentNegotiationManager">
<mvc:message-converters register-defaults="true">
<!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8" />
</bean>
<!-- 将Jackson2HttpMessageConverter的默认格式化输出设为true -->
<bean
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="prettyPrint" value="true" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- REST中根据URL后缀自动判定Content-Type及相应的View -->
<bean id="contentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="ignoreAcceptHeader" value="true" />
<property name="defaultContentType" value="application/json" />
<property name="mediaTypes">
<value>
json=application/json
xml=application/xml
</value>
</property>
</bean>
<!--简化配置: -->
<!--1)自动注册DefaultAnnotationHandlerMapping,AnnotationMethodHandlerAdapter -->
<!--2)提供一些列:数据绑定,数字和日期的format @NumberFormat @DataTimeFormart,xml,json 默认读写支持。 -->
<mvc:annotation-driven />
<!--2.静态资源默认servlet配置 -->
<!-- 1).加入对静态资源处理:js,gif,png 2).允许使用 "/" 做整体映射 -->
<mvc:default-servlet-handler />
<!--3:配置JSP 显示ViewResolver -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理,3.04新增功能,需要重新设置spring-mvc-3.0.xsd -->
<mvc:resources mapping="/res/**" location="/WEB-INF/res/" />
<!--4:扫描web相关的bean -->
<context:component-scan base-package="com.w1hd.zzhnc" />
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8" />
<!-- 指定所上传文件的总大小不能超过2000KB。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 -->
<property name="maxUploadSize" value="200000000" />
</bean>
<bean id="jsonConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>
<!-- pc登录拦截器 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/autoreply/*" />
<mvc:mapping path="/poster/*" />
<mvc:mapping path="/project/*" />
<mvc:mapping path="/report/*" />
<mvc:mapping path="/sale/*" />
<mvc:mapping path="/vanker/*" />
<mvc:mapping path="/home/*" />
<mvc:exclude-mapping path="/sale/chatlogList" />
<mvc:exclude-mapping path="/sale/cleanCatlogList" />
<mvc:exclude-mapping path="/sale/checkChatStatus" />
<mvc:exclude-mapping path="/sale/checkoutStatus" />
<mvc:exclude-mapping path="/sale/sendProudct" />
<mvc:exclude-mapping path="/upload/*" />
<bean class="com.w1hd.zzhnc.interceptor.UserInterceptor">
<property name="allowUrls">
<list>
<value>/login</value>
</list>
</property>
</bean>
</mvc:interceptor>
</mvc:interceptors>
<!-- <task:annotation-driven /> -->
<aop:aspectj-autoproxy proxy-target-class="true" />
</beans>