springmvc.xml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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:mvc="http://www.springframework.org/schema/mvc"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
  7. <!--扫描控制层组件-->
  8. <context:component-scan base-package="com.cdxw.ssm.controller"></context:component-scan>
  9. <!--配置视图解析器-->
  10. <bean id="viewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
  11. <property name="order" value="1"/>
  12. <property name="characterEncoding" value="UTF-8"/>
  13. <property name="templateEngine">
  14. <bean class="org.thymeleaf.spring5.SpringTemplateEngine">
  15. <property name="templateResolver">
  16. <bean class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
  17. <!-- 视图前缀 -->
  18. <property name="prefix" value="/WEB-INF/templates/"/>
  19. <!-- 视图后缀 -->
  20. <property name="suffix" value=".html"/>
  21. <property name="templateMode" value="HTML5"/>
  22. <property name="characterEncoding" value="UTF-8" />
  23. </bean>
  24. </property>
  25. </bean>
  26. </property>
  27. </bean>
  28. <!--配置默认的servlet处理静态资源-->
  29. <mvc:default-servlet-handler/>
  30. <!--开启mvc的注解驱动-->
  31. <mvc:annotation-driven/>
  32. <!--配置视图控制器-->
  33. <mvc:view-controller path="/" view-name="index"></mvc:view-controller>
  34. <!--配置文件上传解析器-->
  35. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"></bean>
  36. <!--拦截器和异常解析器根据实际需求进行配置-->
  37. </beans>