spring-mvc.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:p="http://www.springframework.org/schema/p"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:mvc="http://www.springframework.org/schema/mvc"
  7. xmlns:util="http://www.springframework.org/schema/util"
  8. xsi:schemaLocation="http://www.springframework.org/schema/beans
  9. http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
  10. http://www.springframework.org/schema/context
  11. http://www.springframework.org/schema/context/spring-context-4.1.xsd
  12. http://www.springframework.org/schema/mvc
  13. http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
  14. http://www.springframework.org/schema/util
  15. http://www.springframework.org/schema/util/spring-util-3.2.xsd">
  16. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  17. <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
  18. <property name="prefix" value="/"/>
  19. <property name="suffix" value=".jsp"/>
  20. </bean>
  21. <!-- <mvc:annotation-driven /> -->
  22. <mvc:annotation-driven>
  23. <mvc:message-converters>
  24. <ref bean="fastJsonHttpMessageConverter"/>
  25. </mvc:message-converters>
  26. </mvc:annotation-driven>
  27. <bean id="fastJsonHttpMessageConverter"
  28. class="org.cs.core.util.JsonHttpMessageConverter">
  29. <!-- <bean id="fastJsonHttpMessageConverter"
  30. class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> -->
  31. <property name="supportedMediaTypes">
  32. <list>
  33. <value>application/json;charset=UTF-8</value>
  34. <value>text/html;charset=UTF-8</value><!-- 避免IE出现下载JSON文件的情况 -->
  35. </list>
  36. </property>
  37. <property name="features">
  38. <util:list>
  39. <value>WriteMapNullValue</value>
  40. <value>WriteNullStringAsEmpty</value>
  41. <value>WriteNullNumberAsZero</value>
  42. <value>WriteNullListAsEmpty</value>
  43. </util:list>
  44. </property>
  45. </bean>
  46. <context:component-scan base-package="org.cs.*.ctl" />
  47. <context:component-scan base-package="org.cs.*.*.ctl"/>
  48. <context:component-scan base-package="org.cs.web.*"/>
  49. <mvc:interceptors>
  50. <mvc:interceptor>
  51. <mvc:mapping path="/rest/**"/>
  52. <bean id="authCheckInteceptor" class="org.cs.ws.inteceptor.AuthCheckInteceptor"> </bean>
  53. </mvc:interceptor>
  54. <mvc:interceptor>
  55. <mvc:mapping path="/**"/>
  56. <bean id="sessionInterceptor" class="org.cs.mgr.util.SessionInterceptor">
  57. <property name="excludes">
  58. <list>
  59. <value>/login</value>
  60. <value>/rest</value>
  61. <value>/mgr/login</value>
  62. <value>/version/getAndroid</value>
  63. <value>/admin</value>
  64. <value>/tim</value>
  65. <value>/oauth2wx</value>
  66. <value>/oauth2me</value>
  67. <value>/area</value>
  68. <value>/oauth2wx</value>
  69. <value>/oauth2me</value>
  70. <value>/web/mgmUserCtl/register</value>
  71. <value>/file</value>
  72. </list>
  73. </property>
  74. </bean>
  75. </mvc:interceptor>
  76. </mvc:interceptors>
  77. <!--<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
  78. <property name="converters">
  79. <set>
  80. <bean class="org.cs.core.util.StringToEnumConverterFactory" />
  81. </set>
  82. </property>
  83. </bean>
  84. <mvc:annotation-driven conversion-service="conversionService" />-->
  85. <!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 -->
  86. <bean id="multipartResolver"
  87. class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  88. <!-- 指定所上传文件的总大小不能超过2000KB。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 -->
  89. <property name="maxUploadSize" value="419430400"/>
  90. </bean>
  91. <!-- SpringMVC在超出上传文件限制时,会抛出org.springframework.web.multipart.MaxUploadSizeExceededException -->
  92. <!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 -->
  93. <bean id="exceptionResolver"
  94. class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
  95. <property name="exceptionMappings">
  96. <props>
  97. <!-- 遇到MaxUploadSizeExceededException异常时,自动跳转到/WEB-INF/jsp/error_fileupload.jsp页面
  98. <prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">
  99. iface/error_fileupload
  100. </prop>-->
  101. <prop key="java.lang.Exception">common/error</prop>
  102. </props>
  103. </property>
  104. </bean>
  105. </beans>