|
楼主 |
发表于 2024-4-8 16:43:04
|
显示全部楼层
servlet配置文件
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- 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">
- <!--组件扫描-->
- <context:component-scan base-package="com.powernode.springmvc.controller"/>
- <!--视图解析器-->
- <bean id="thymeleafViewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
- <!--作用于视图渲染的过程中,可以设置视图渲染后输出时采用的编码字符集-->
- <property name="characterEncoding" value="UTF-8"/>
- <!--如果配置多个视图解析器,它来决定优先使用哪个视图解析器,它的值越小优先级越高-->
- <property name="order" value="1"/>
- <!--当 ThymeleafViewResolver 渲染模板时,会使用该模板引擎来解析、编译和渲染模板-->
- <property name="templateEngine">
- <bean class="org.thymeleaf.spring5.SpringTemplateEngine">
- <!--用于指定 Thymeleaf 模板引擎使用的模板解析器。模板解析器负责根据模板位置、模板资源名称、文件编码等信息,加载模板并对其进行解析-->
- <property name="templateResolver">
- <bean class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
- <!--设置模板文件的位置(前缀)-->
- <property name="prefix" value="/WEB-INF/templates/"/>
- <!--设置模板文件后缀(后缀),Thymeleaf文件扩展名不一定是html,也可以是其他,例如txt,大部分都是html-->
- <property name="suffix" value=".html"/>
- <!--设置模板类型,例如:HTML,TEXT,JAVASCRIPT,CSS等-->
- <property name="templateMode" value="HTML"/>
- <!--用于模板文件在读取和解析过程中采用的编码字符集-->
- <property name="characterEncoding" value="UTF-8"/>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
- </beans>
复制代码 |
|