spring-mvc.xml 6.5 KB
<?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>