引入依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

我们的bootstarter已经整合过了,不需要版本坐标。

创建

创建一个HTML文件。

我们需要再<html>标签里面加点东西。

运行

我直接打开这个html时,他是这样的。

因为我们需要web服务对thymeleaf语法进行处理。

配置

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**

我们也可以再SpringBoot的配置文件中,配置相关设置。

至于使用方法,请参考其他资料吧。

最后修改:2022 年 09 月 22 日
如果觉得我的文章对你有用,请随意赞赏