spring-servlet.xml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:aop="http://www.springframework.org/schema/aop"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans.xsd
  8. http://www.springframework.org/schema/mvc
  9. http://www.springframework.org/schema/mvc/spring-mvc.xsd
  10. http://www.springframework.org/schema/context
  11. http://www.springframework.org/schema/context/spring-context.xsd
  12. http://www.springframework.org/schema/aop
  13. http://www.springframework.org/schema/aop/spring-aop-4.2.xsd">
  14. <!-- MVC转换 -->
  15. <mvc:annotation-driven />
  16. <mvc:default-servlet-handler />
  17. <!-- 自动扫描bean,把作了注解的Controller转换为bean 注意不能扫描全包,否则跟spring上下文冲突,会导致上下文工具类失效-->
  18. <context:component-scan base-package="com.lote.wms.task.controller" />
  19. <!-- CGLIB动态代理 -->
  20. <aop:aspectj-autoproxy proxy-target-class="true" />
  21. <!-- 模型视图名称添加前后缀 -->
  22. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/views/" p:suffix=".jsp" />
  23. <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
  24. <!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />-->
  25. <!-- 文件上传 -->
  26. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" p:defaultEncoding="utf-8" />
  27. <!-- 字符串处理 -->
  28. <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" p:ignoreDefaultModelOnRedirect="true">
  29. <property name="messageConverters">
  30. <list>
  31. <bean
  32. class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
  33. </list>
  34. </property>
  35. </bean>
  36. <!-- spring mvc 4.0+的跨域配置 -->
  37. <mvc:cors>
  38. <mvc:mapping path="/**" allowed-origins="*" allow-credentials="true" max-age="1800" allowed-methods="GET,POST,OPTIONS"/>
  39. </mvc:cors>
  40. </beans>