spring-mvc.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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:context="http://www.springframework.org/schema/context"
  5. xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  6. xmlns:jee="http://www.springframework.org/schema/jee"
  7. xmlns:tx="http://www.springframework.org/schema/tx"
  8. xmlns:jpa="http://www.springframework.org/schema/data/jpa"
  9. xmlns:aop="http://www.springframework.org/schema/aop"
  10. xmlns:mvc="http://www.springframework.org/schema/mvc"
  11. xsi:schemaLocation="
  12. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  13. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  14. http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
  15. http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
  16. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
  17. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
  18. http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
  19. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"
  20. default-lazy-init="true">
  21. <!-- SpringMVC相关Bean配置 -->
  22. <context:component-scan base-package="com.*.web" />
  23. <context:annotation-config/>
  24. <!--可以完成日期自动转换功能-->
  25. <mvc:annotation-driven>
  26. <!-- SpringMVC下载器 -->
  27. <mvc:message-converters>
  28. <bean class="com.core.util.file.DownloadHttpMessageConverter" />
  29. </mvc:message-converters>
  30. </mvc:annotation-driven>
  31. <!-- 使用注解映射 -->
  32. <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
  33. <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
  34. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
  35. <property name="messageConverters">
  36. <list>
  37. <ref bean="stringHttpMessageConverter"/>
  38. <ref bean="mappingJacksonHttpMessageConverter"/>
  39. </list>
  40. </property>
  41. </bean>
  42. <bean id="stringHttpMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
  43. <property name="supportedMediaTypes">
  44. <list>
  45. <value>text/plain;charset=UTF-8</value>
  46. </list>
  47. </property>
  48. </bean>
  49. <!-- 让controller 返回json的配置 -->
  50. <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
  51. <property name="supportedMediaTypes">
  52. <list>
  53. <value>text/html;charset=UTF-8</value>
  54. </list>
  55. </property>
  56. </bean>
  57. <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀
  58. <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  59. <property name="redirectHttp10Compatible" value="false"/>
  60. <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
  61. <property name="contentType" value="text/html;charset=UTF-8" />
  62. <property name="prefix" value="/WEB-INF/view/" />
  63. <property name="suffix" value=".jsp" />
  64. </bean>
  65. -->
  66. <!-- FreeMarker视图解析 ,在这里配置后缀名ftl和视图解析器。。-->
  67. <bean id="freemarkerViewResolver" class="com.core.web.springmvc.RichFreeMarkerViewResolver">
  68. <property name="prefix" value="/view/"/>
  69. <property name="suffix" value=".jsp"/>
  70. <property name="contentType" value="text/html; charset=UTF-8"/>
  71. <property name="exposeRequestAttributes" value="false"/>
  72. <property name="exposeSessionAttributes" value="false"/>
  73. <property name="exposeSpringMacroHelpers" value="true"/>
  74. <!-- <property name="attributesMap">
  75. <map>
  76. <entry key="enum_show">
  77. <bean class="com.core.util.EnumValueShow"></bean>
  78. </entry>
  79. </map>
  80. </property> -->
  81. </bean>
  82. <!-- freemarker的配置 -->
  83. <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
  84. <property name="templateLoaderPath" value="/WEB-INF"/>
  85. <property name="freemarkerVariables">
  86. <map>
  87. <!--后台管理权限控制-->
  88. <entry key="pop_perm" value-ref="pop_perm"/>
  89. <entry key="enum_show" value-ref="enum_show" />
  90. </map>
  91. </property>
  92. <property name="freemarkerSettings">
  93. <props>
  94. <prop key="template_update_delay">0</prop>
  95. <prop key="defaultEncoding">UTF-8</prop>
  96. <prop key="url_escaping_charset">UTF-8</prop>
  97. <prop key="locale">zh_CN</prop>
  98. <prop key="boolean_format">true,false</prop>
  99. <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
  100. <prop key="date_format">yyyy-MM-dd</prop>
  101. <prop key="time_format">HH:mm:ss</prop>
  102. <prop key="number_format">0.######</prop>
  103. <prop key="whitespace_stripping">true</prop>
  104. </props>
  105. </property>
  106. </bean>
  107. <!-- 让springmvc支持文件上传 -->
  108. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  109. <property name="maxInMemorySize" value="2048"></property>
  110. <property name="maxUploadSize" value="1000000000"/>
  111. <property name="uploadTempDir" value="tmoDir"></property>
  112. </bean>
  113. <!--把标签定义包含进来-->
  114. <import resource="spring-directive.xml"/>
  115. </beans>