Spring4中配置Thymeleaf3视图

引入必要的依赖文件:

1
2
3
4
5
6
<!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring4 -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>

配置Thymeleaf试图解析器:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!-- Thymeleaf视图解析器 -->
<bean id="viewResolver"
class="org.thymeleaf.spring4.view.ThymeleafViewResolver"
p:templateEngine-ref="templateEngine"
p:characterEncoding="UTF-8" />
<!-- 模板引擎 -->
<bean id="templateEngine"
class="org.thymeleaf.spring4.SpringTemplateEngine"
p:templateResolver-ref="templateResolver" />
<!-- 模板解析器 -->
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"
p:prefix="/WEB-INF/templates/"
p:suffix=".html"
p:templateMode="HTML5"
p:cacheable="false"
p:characterEncoding="UTF-8"/>

请作者喝瓶肥宅水🥤

0