spring-servlet.xml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
  4. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
  5. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  6. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
  7. <context:annotation-config />
  8. <!-- 把标记了@Controller注解的类转换为bean -->
  9. <context:component-scan base-package="com.jsjty" use-default-filters="false">
  10. <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
  11. </context:component-scan>
  12. <mvc:annotation-driven conversion-service="conversionService"/>
  13. <bean id="conversionService"
  14. class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
  15. <property name="formatters">
  16. <set>
  17. <bean class="com.jsjty.common.DateFormatter"></bean>
  18. </set>
  19. </property>
  20. </bean>
  21. <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
  22. <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
  23. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
  24. <bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
  25. <bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/>
  26. <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
  27. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
  28. <property name="prefix" value="/WEB-INF/view/jsp/" />
  29. <property name="suffix" value=".jsp" />
  30. </bean>
  31. </beans>