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
    7. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    8. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
    9. ">
    10. <!--扫描组件-->
    11. <context:component-scan base-package="com.atguigu.rest"></context:component-scan>
    12. <!-- 配置Thymeleaf视图解析器 -->
    13. <bean id="viewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
    14. <property name="order" value="1"/>
    15. <property name="characterEncoding" value="UTF-8"/>
    16. <property name="templateEngine">
    17. <bean class="org.thymeleaf.spring5.SpringTemplateEngine">
    18. <property name="templateResolver">
    19. <bean class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
    20. <!-- 视图前缀 -->
    21. <property name="prefix" value="/WEB-INF/templates/"/>
    22. <!-- 视图后缀 -->
    23. <property name="suffix" value=".html"/>
    24. <property name="templateMode" value="HTML5"/>
    25. <property name="characterEncoding" value="UTF-8"/>
    26. </bean>
    27. </property>
    28. </bean>
    29. </property>
    30. </bean>
    31. <!-- <mvc:view-controller path="/" view-name="index"></mvc:view-controller>-->
    32. <!--开放对静态资源的访问-->
    33. <mvc:default-servlet-handler/>
    34. <!--开启MVC注解驱动-->
    35. <mvc:annotation-driven/>
    36. </beans>