dispatcher-servlet.xml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <beans xmlns="http://www.springframework.org/schema/beans"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:mvc="http://www.springframework.org/schema/mvc"
  5. xmlns:p="http://www.springframework.org/schema/p"
  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/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
  9. <context:component-scan base-package="com.yihu">
  10. <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
  11. <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
  12. </context:component-scan>
  13. <!-- 允许访问指定路径下的静态资源 -->
  14. <mvc:resources location="WEB-INF/" mapping="/WEB-INF/**" />
  15. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  16. <property name="prefix" value="/WEB-INF/jsp/"/>
  17. <property name="suffix" value=".jsp"/>
  18. </bean>
  19. <!-- 自定义json转换类(时间类型) -->
  20. <mvc:annotation-driven>
  21. <mvc:message-converters>
  22. <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
  23. <property name="objectMapper">
  24. <bean class="com.fasterxml.jackson.databind.ObjectMapper">
  25. <property name="dateFormat">
  26. <bean class="java.text.SimpleDateFormat">
  27. <constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss"/>
  28. </bean>
  29. </property>
  30. </bean>
  31. </property>
  32. </bean>
  33. </mvc:message-converters>
  34. </mvc:annotation-driven>
  35. </beans>