springmvc.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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:mvc="http://www.springframework.org/schema/mvc"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:task="http://www.springframework.org/schema/task"
  7. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
  8. http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.3.xsd
  9. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  10. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
  11. <!-- 配置注解驱动 -->
  12. <mvc:annotation-driven>
  13. <mvc:message-converters>
  14. <bean
  15. class="org.springframework.http.converter.StringHttpMessageConverter">
  16. <property name="supportedMediaTypes">
  17. <list>
  18. <value>application/json;charset=UTF-8</value>
  19. <value>text/html;charset=UTF-8</value>
  20. </list>
  21. </property>
  22. </bean>
  23. <!-- 启动JSON格式的配置,自动将格式转换成JSON格式,不需要其他类 -->
  24. <bean id="jacksonMessageConverter"
  25. class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
  26. <property name="supportedMediaTypes"
  27. value="application/json;charset=UTF-8" />
  28. </bean>
  29. </mvc:message-converters>
  30. </mvc:annotation-driven>
  31. <!-- 配置包扫描器 -->
  32. <context:component-scan base-package="com.ncjt.ch.sm.controller"></context:component-scan>
  33. <context:component-scan base-package="com.ncjt.ch.eg.api.device.controller"></context:component-scan>
  34. <context:component-scan base-package="com.ncjt.ch.eg.qrcode.controller"></context:component-scan>
  35. <!-- 配置spring定时任务 -->
  36. <context:component-scan base-package="com.ncjt.ch.eg.component"></context:component-scan>
  37. <task:scheduler id="scheduler" pool-size="3"/>
  38. <task:scheduled-tasks scheduler="scheduler">
  39. <task:scheduled ref="simpleTask" method="weiXiaoVisitor" cron="10 * * * * ?"/>
  40. <!-- <task:scheduled ref="simpleTask" method="schoolGateRecordUpload" cron="10 * * * * ?"/>-->
  41. <task:scheduled ref="simpleTask" method="schoolGateRecordUpload" cron="0 15 10 * * ?" />
  42. </task:scheduled-tasks>
  43. <!-- 视图解析器 -->
  44. <bean
  45. class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  46. <property name="prefix" value="/WEB-INF/JSP/" />
  47. <property name="suffix" value=".jsp" />
  48. </bean>
  49. <!-- 注册multipart解析器,这个id是固定的,由DispatcherServlet直接调用 -->
  50. <bean id="multipartResolver"
  51. class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  52. <property name="defaultEncoding" value="utf-8" />
  53. <property name="maxUploadSize" value="10240000"></property>
  54. <!-- 改属性延迟解析,当进入Controller时开始解析,这样就可以捕获到异常,否则由SpringMVC抛出异常时无法捕获 -->
  55. <property name="resolveLazily" value="true"></property>
  56. </bean>
  57. <!-- 对静态资源文件请求的映射,否则客户端无法得到js文件和css文件 -->
  58. <!-- 将/js/**的所有请求链接映射到/WEB-INF/js/目录下,即在/WEB-INF/js/目录 -->
  59. <!-- 下查找请求的js文件和css文件 -->
  60. <mvc:resources location="/WEB-INF/css/" mapping="/css/**"></mvc:resources>
  61. <mvc:resources location="/WEB-INF/image/"
  62. mapping="/image/**"></mvc:resources>
  63. <mvc:resources location="/WEB-INF/jub/" mapping="/jub/**"></mvc:resources>
  64. <mvc:resources location="/WEB-INF/js/" mapping="/js/**"></mvc:resources>
  65. <mvc:resources location="/WEB-INF/static/" mapping="/static/**"></mvc:resources>
  66. <mvc:resources location="/WEB-INF/uploadImages/"
  67. mapping="/uploadImages/**"></mvc:resources>
  68. <mvc:resources location="/WEB-INF/showImages/"
  69. mapping="/showImages/**"></mvc:resources>
  70. <mvc:resources location="/download/" mapping="/download/**"></mvc:resources>
  71. <!-- 这个配置可以替代上面的配置, -->
  72. <!-- 区别在于,这时Spring MVC会直接使用请求的链接作为文件的位置, -->
  73. <!-- 而不能使用映射后的文件位置 -->
  74. <!-- <mvc:default-servlet-handler /> -->
  75. <!-- 配置拦截器,用于解决AJAX跨域问题 -->
  76. <!-- <mvc:interceptors> -->
  77. <!-- <mvc:interceptor> -->
  78. <!-- <mvc:mapping path="/**" /> -->
  79. <!-- <bean class="com.jgxl.eid.interceptor.CommonInterceptor"> -->
  80. <!-- <property name="excludedUrls"> -->
  81. <!-- <list> -->
  82. <!-- <value>/</value> -->
  83. <!-- </list> -->
  84. <!-- </property> -->
  85. <!-- </bean> -->
  86. <!-- </mvc:interceptor> -->
  87. <!-- </mvc:interceptors> -->
  88. <!-- 配置拦截器 -->
  89. <!-- <mvc:interceptors> -->
  90. <!-- <mvc:interceptor> -->
  91. <!-- <mvc:mapping path="/*" /> -->
  92. <!-- <mvc:exclude-mapping path="/" /> -->
  93. <!-- <mvc:exclude-mapping path="/test"/> -->
  94. <!-- <bean class="com.plk.jdz.interceptor.SessionIdCheckInterceptor"> -->
  95. <!-- <property name="excludedUrls"> -->
  96. <!-- <list> -->
  97. <!-- <value>/checkLogin</value> -->
  98. <!-- </list> -->
  99. <!-- </property> -->
  100. <!-- </bean> -->
  101. <!-- </mvc:interceptor> -->
  102. <!-- </mvc:interceptors> -->
  103. <!-- 配置异常处理器 -->
  104. <!-- <bean id="handlerExceptionResolver" -->
  105. <!-- class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> -->
  106. <!-- <property name="exceptionMappings"> -->
  107. <!-- <props> -->
  108. <!-- <prop key="com.plk.jdz.exception.NotLoggedException">redirect:/</prop> -->
  109. <!-- </props> -->
  110. <!-- </property> -->
  111. <!-- </bean> -->
  112. </beans>