<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-4.3.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.3.xsd">
<!-- ===========注解扫描:设置使用注解的类所在的jar包=========== -->
<context:component-scan base-package="com.treasureFinal.p2padmin, com.treasureFinal.p2pweb">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>
<!-- ===========注解扫描:设置使用注解的类所在的jar包=========== -->
<!-- ===========启用注解驱动===========-->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" p:supportedMediaTypes="*/*" />
</mvc:message-converters>
</mvc:annotation-driven>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
<!-- ===========启用注解驱动===========-->
<!-- ===========配置视图 解析器===========-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="100" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- ===========配置视图 解析器===========-->
<!-- 对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 -->
<mvc:default-servlet-handler />
<context:property-placeholder ignore-unresolvable="true" location="classpath:properties/*.properties" />
<!-- <context:component-scan base-package="com.treasureFinal.p2padmin" /> -->
<!-- <context:component-scan base-package="com.treasureFinal.p2pweb" /> -->
<context:annotation-config />
<mvc:annotation-driven />
<import resource="classpath:spring/spring-aop.xml"/>
<import resource="classpath:spring/spring-task.xml"/>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="10" />
<!-- 配置上传组件 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
p:maxUploadSize="5120000" p:maxInMemorySize="51200" p:defaultEncoding="UTF-8"
p:uploadTempDir="/upload/" />
<!-- 配置json字符编码 -->
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
</list>
</property>
</bean>
<!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 -->
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">error/error_fileupload</prop>
</props>
</property>
</bean>
<!-- 配置消息转换机制 -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter"><constructor-arg value="UTF-8" /></bean>
<!-- 对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 -->
<mvc:default-servlet-handler />
<!-- 静态资源映射 -->
<mvc:resources mapping="/version/**" location="/treasureFinal/V1.0.0/" cache-period="31536000"/>
<mvc:resources mapping="/topversion/**" location="/treasureFinal/T1.0.0/" cache-period="31536000"/>
<mvc:resources mapping="/wapversion/**" location="/treasureFinal/W1.0.0/" cache-period="31536000"/>
<mvc:resources mapping="/upload/**" location="/upload/" cache-period="31536000"/>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="${admin.managerPath}/**" />
<bean class="com.treasureFinal.p2padmin.intercepor.AdminIntercepor" />
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="com.treasureFinal.p2pweb.intercepor.WebsiteIntercepor" />
</mvc:interceptor>
</mvc:interceptors>
</beans>
<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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-4.3.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.3.xsd">
<!-- ===========注解扫描:设置使用注解的类所在的jar包=========== -->
<context:component-scan base-package="com.treasureFinal.p2padmin, com.treasureFinal.p2pweb">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>
<!-- ===========注解扫描:设置使用注解的类所在的jar包=========== -->
<!-- ===========启用注解驱动===========-->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" p:supportedMediaTypes="*/*" />
</mvc:message-converters>
</mvc:annotation-driven>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
<!-- ===========启用注解驱动===========-->
<!-- ===========配置视图 解析器===========-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="100" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- ===========配置视图 解析器===========-->
<!-- 对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 -->
<mvc:default-servlet-handler />
<context:property-placeholder ignore-unresolvable="true" location="classpath:properties/*.properties" />
<!-- <context:component-scan base-package="com.treasureFinal.p2padmin" /> -->
<!-- <context:component-scan base-package="com.treasureFinal.p2pweb" /> -->
<context:annotation-config />
<mvc:annotation-driven />
<import resource="classpath:spring/spring-aop.xml"/>
<import resource="classpath:spring/spring-task.xml"/>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="10" />
<!-- 配置上传组件 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
p:maxUploadSize="5120000" p:maxInMemorySize="51200" p:defaultEncoding="UTF-8"
p:uploadTempDir="/upload/" />
<!-- 配置json字符编码 -->
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
</list>
</property>
</bean>
<!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 -->
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">error/error_fileupload</prop>
</props>
</property>
</bean>
<!-- 配置消息转换机制 -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter"><constructor-arg value="UTF-8" /></bean>
<!-- 对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 -->
<mvc:default-servlet-handler />
<!-- 静态资源映射 -->
<mvc:resources mapping="/version/**" location="/treasureFinal/V1.0.0/" cache-period="31536000"/>
<mvc:resources mapping="/topversion/**" location="/treasureFinal/T1.0.0/" cache-period="31536000"/>
<mvc:resources mapping="/wapversion/**" location="/treasureFinal/W1.0.0/" cache-period="31536000"/>
<mvc:resources mapping="/upload/**" location="/upload/" cache-period="31536000"/>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="${admin.managerPath}/**" />
<bean class="com.treasureFinal.p2padmin.intercepor.AdminIntercepor" />
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="com.treasureFinal.p2pweb.intercepor.WebsiteIntercepor" />
</mvc:interceptor>
</mvc:interceptors>
</beans>