mybatis-servlet.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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" xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:mvc="http://www.springframework.org/schema/mvc"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans.xsd
  7. http://www.springframework.org/schema/mvc
  8. http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
  9. http://www.springframework.org/schema/context
  10. http://www.springframework.org/schema/context/spring-context.xsd">
  11. <mvc:default-servlet-handler/>
  12. <!--RequestMappingHandlerAdapter-->
  13. <mvc:annotation-driven>
  14. <mvc:message-converters>
  15. <ref bean="stringHttpMessageConverter"/>
  16. <ref bean="marshallingHttpMessageConverter"/>
  17. <ref bean="mappingJackson2HttpMessageConverter"/>
  18. </mvc:message-converters>
  19. </mvc:annotation-driven>
  20. <context:component-scan base-package="com.yc.education.controller.demo"/>
  21. <context:component-scan base-package="com.yc.education.controller"/>
  22. <bean id="stringHttpMessageConverter"
  23. class="org.springframework.http.converter.StringHttpMessageConverter"/>
  24. <bean id="marshallingHttpMessageConverter"
  25. class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
  26. <property name="marshaller" ref="castorMarshaller"/>
  27. <property name="unmarshaller" ref="castorMarshaller"/>
  28. </bean>
  29. <bean id="mappingJackson2HttpMessageConverter"
  30. class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
  31. <property name="supportedMediaTypes">
  32. <list>
  33. <value>application/json</value>
  34. <value>application/xml</value>
  35. <value>text/html</value>
  36. <value>text/plain</value>
  37. <value>text/xml</value>
  38. </list>
  39. </property>
  40. </bean>
  41. <bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"/>
  42. <!--信息转换 - 结束-->
  43. <bean id="contentNegotiationManagerFactoryBean"
  44. class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
  45. <property name="defaultContentType" value="text/html"/>
  46. <property name="ignoreAcceptHeader" value="true"/>
  47. <property name="favorPathExtension" value="true"/>
  48. <property name="favorParameter" value="false"/>
  49. <property name="mediaTypes">
  50. <map>
  51. <entry key="atom" value="application/atom+xml"/>
  52. <entry key="html" value="text/html"/>
  53. <entry key="json" value="application/json"/>
  54. </map>
  55. </property>
  56. </bean>
  57. <!--内容协商-->
  58. <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
  59. <property name="contentNegotiationManager">
  60. <bean class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
  61. <property name="defaultContentType" value="text/html"/>
  62. <property name="mediaTypes">
  63. <map>
  64. <entry key="json" value="application/json"/>
  65. <entry key="xml" value="application/xml"/>
  66. <entry key="html" value="text/html"/>
  67. </map>
  68. </property>
  69. </bean>
  70. </property>
  71. <property name="viewResolvers">
  72. <list>
  73. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  74. <property name="prefix" value="/WEB-INF/jsp/"/>
  75. <property name="suffix" value=".jsp"/>
  76. </bean>
  77. </list>
  78. </property>
  79. <property name="defaultViews">
  80. <list>
  81. <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
  82. <bean class="org.springframework.web.servlet.view.xml.MarshallingView">
  83. <property name="marshaller" ref="castorMarshaller"/>
  84. </bean>
  85. </list>
  86. </property>
  87. </bean>
  88. <!--国际化-->
  89. <bean id="messageSource"
  90. class="org.springframework.context.support.ResourceBundleMessageSource">
  91. <property name="defaultEncoding" value="UTF-8"/>
  92. <property name="basenames">
  93. <list>
  94. <value>messages.welcome</value>
  95. </list>
  96. </property>
  97. </bean>
  98. <!--文件上传-->
  99. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  100. <property name="maxUploadSize" value="10000000000"/>
  101. </bean>
  102. <!-- 全局拦截器配置文件 Start -->
  103. <mvc:interceptors>
  104. <mvc:interceptor>
  105. <mvc:mapping path="/**"/>
  106. <bean class="com.yc.education.interceptor.GlobalInterceptor" />
  107. </mvc:interceptor>
  108. </mvc:interceptors>
  109. <!-- 全局拦截器配置文件 End -->
  110. </beans>