172 lines
8.6 KiB
XML
172 lines
8.6 KiB
XML
<?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"
|
||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
|
||
http://www.springframework.org/schema/websocket http://www.springframework.org/schema/websocket/spring-websocket.xsd">
|
||
|
||
<description>Spring MVC Configuration</description>
|
||
|
||
<context:component-scan base-package="com.hx.slj.modules.job"/>
|
||
<!-- 加载配置属性文件 -->
|
||
<context:property-placeholder ignore-unresolvable="true" location="classpath:jeeplus.properties"/>
|
||
<!-- 使用Annotation自动注册Bean,只扫描@Controller -->
|
||
<context:component-scan base-package="com.hx.slj" use-default-filters="false"><!-- base-package 如果多个,用“,”分隔 -->
|
||
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
|
||
</context:component-scan>
|
||
|
||
<!-- 默认的注解映射的支持,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping -->
|
||
<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的默认格式化输出为false -->
|
||
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
|
||
<property name="supportedMediaTypes">
|
||
<list>
|
||
<value>application/json;charset=UTF-8</value>
|
||
</list>
|
||
</property>
|
||
<property name="prettyPrint" value="false"/>
|
||
<property name="objectMapper">
|
||
<bean class="com.hx.slj.common.mapper.JsonMapper">
|
||
<property name="timeZone" value="GMT+8"/>
|
||
</bean>
|
||
</property>
|
||
</bean>
|
||
<!-- 使用XML格式输出数据 -->
|
||
<bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
|
||
<constructor-arg>
|
||
<bean class="org.springframework.oxm.xstream.XStreamMarshaller">
|
||
<property name="streamDriver">
|
||
<bean class="com.thoughtworks.xstream.io.xml.StaxDriver"/>
|
||
</property>
|
||
<property name="annotatedClasses">
|
||
<list>
|
||
<value>com.hx.slj.common.persistence.BaseEntity</value>
|
||
</list>
|
||
</property>
|
||
</bean>
|
||
</constructor-arg>
|
||
<property name="supportedMediaTypes" value="application/xml"></property>
|
||
</bean>
|
||
</mvc:message-converters>
|
||
</mvc:annotation-driven>
|
||
|
||
<!-- REST中根据URL后缀自动判定Content-Type及相应的View -->
|
||
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||
<property name="mediaTypes">
|
||
<map>
|
||
<entry key="xml" value="application/xml"/>
|
||
<entry key="json" value="application/json"/>
|
||
</map>
|
||
</property>
|
||
<property name="ignoreAcceptHeader" value="true"/>
|
||
<property name="favorPathExtension" value="true"/>
|
||
</bean>
|
||
|
||
<!-- 定义视图文件解析 -->
|
||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||
<property name="prefix" value="${web.view.prefix}"/>
|
||
<property name="suffix" value="${web.view.suffix}"/>
|
||
</bean>
|
||
<!-- <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />-->
|
||
|
||
<!-- 对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 -->
|
||
<mvc:default-servlet-handler/>
|
||
|
||
<!-- 静态资源映射 -->
|
||
<mvc:resources mapping="/static/**" location="/static/" cache-period="31536000"/>
|
||
|
||
<!-- 定义无Controller的path<->view直接映射 -->
|
||
<mvc:view-controller path="/" view-name="redirect:${web.view.index}"/>
|
||
|
||
<!-- 拦截器配置,拦截顺序:先执行后定义的,排在第一位的最后执行。-->
|
||
<mvc:interceptors>
|
||
<!--配置登陆访问然后直接退出-->
|
||
<mvc:interceptor>
|
||
<mvc:mapping path="${adminPath}/login"/>
|
||
<mvc:exclude-mapping path="${adminPath}/zyb/**"/>
|
||
<bean class="com.hx.slj.modules.sys.interceptor.LoginZiInterceptor"></bean>
|
||
</mvc:interceptor>
|
||
|
||
<mvc:interceptor>
|
||
<mvc:mapping path="${adminPath}/**"/>
|
||
<mvc:exclude-mapping path="${adminPath}/"/>
|
||
<mvc:exclude-mapping path="${adminPath}/login"/>
|
||
<mvc:exclude-mapping path="${adminPath}/sys/menu/tree"/>
|
||
<mvc:exclude-mapping path="${adminPath}/zybGrzx/**"/>
|
||
<mvc:exclude-mapping path="${adminPath}/zfry/**"/>
|
||
<mvc:exclude-mapping path="${adminPath}/oa/oaNotify/self/count"/>
|
||
<mvc:exclude-mapping path="${adminPath}/oa/oaNotify/self/count"/>
|
||
<bean class="com.hx.slj.modules.sys.interceptor.LogInterceptor"/>
|
||
</mvc:interceptor>
|
||
<!-- 手机视图拦截器 -->
|
||
<mvc:interceptor>
|
||
<mvc:mapping path="/**"/>
|
||
<bean class="com.hx.slj.modules.sys.interceptor.MobileInterceptor"/>
|
||
</mvc:interceptor>
|
||
<!-- 多个拦截器,顺序执行 -->
|
||
<mvc:interceptor>
|
||
<mvc:mapping path="${adminPath}/**"/>
|
||
<!--被排除拦截的资源-->
|
||
<mvc:exclude-mapping path="${adminPath}/zybGrzx/grzxLogin"/>
|
||
<mvc:exclude-mapping path="${adminPath}/zybGrzx/grzxSubmit"/>
|
||
<mvc:exclude-mapping path="${adminPath}/zybGrzx/sendYzm"/>
|
||
<mvc:exclude-mapping path="${adminPath}/zybGrzx/checkDxyz"/>
|
||
<mvc:exclude-mapping path="${adminPath}/zybGrzx/getQyxx"/>
|
||
<mvc:exclude-mapping path="${adminPath}/zybGrzx/grzxDl"/>
|
||
<bean class="com.hx.slj.modules.zybGrzx.config.HandlerLJInterceptor"></bean>
|
||
</mvc:interceptor>
|
||
|
||
|
||
</mvc:interceptors>
|
||
<mvc:cors>
|
||
<mvc:mapping path="/**"
|
||
allowed-origins="*"
|
||
allowed-methods="POST, GET, OPTIONS, DELETE, PUT"
|
||
allowed-headers="Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
|
||
allow-credentials="true" />
|
||
</mvc:cors>
|
||
|
||
<!-- 支持Shiro对Controller的方法级AOP安全控制 begin-->
|
||
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
|
||
depends-on="lifecycleBeanPostProcessor">
|
||
<property name="proxyTargetClass" value="true"/>
|
||
</bean>
|
||
|
||
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
||
<property name="exceptionMappings">
|
||
<props>
|
||
<prop key="org.apache.shiro.authz.UnauthorizedException">error/403</prop>
|
||
<prop key="java.lang.Throwable">error/500</prop>
|
||
</props>
|
||
</property>
|
||
</bean>
|
||
<!-- 支持Shiro对Controller的方法级AOP安全控制 end -->
|
||
|
||
<!-- 上传文件拦截,设置最大上传文件大小 1G=1024*1024*1024(B)=1073741824 bytes -->
|
||
|
||
<!-- <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||
<property name="maxUploadSize" value="4097152" />
|
||
<property name="maxInMemorySize" value="4097152"/>
|
||
<property name="defaultEncoding">
|
||
<value>utf-8</value>
|
||
</property>
|
||
</bean>-->
|
||
|
||
<!-- 定义文件上传解析器 -->
|
||
<bean id="multipartResolver"
|
||
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||
<!-- 设定默认编码 -->
|
||
<property name="defaultEncoding" value="UTF-8"></property>
|
||
<!-- 设定文件上传的最大值5MB,5*1024*1024 -->
|
||
<property name="maxUploadSize" value="104857600"></property>
|
||
</bean>
|
||
|
||
</beans>
|