一、加依赖,在pom.xml中加入以下依赖
<!-- thymeleaf 的支持 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
二、thymeleaf有默认文件路径,在 resources文件夹下新建templates文件夹(这里我是又建了一个子文件thymeleaf)
三、在application.properties中加入配置文件(这里提供两种配置,一种简洁配置,一种复杂一点的配置)
#thymeleaf 简洁配置
spring.thymeleaf.prefix:classpath:/templates/thymeleaf/
spring.thymeleaf.suffix:.html
#thymeleaf 丰富配置
#spring.thymeleaf.prefix=classpath:/templates/thymeleaf/
#spring.thymeleaf.mode=HTML5
#spring.thymeleaf.check-template-location=true
#spring.thymeleaf.encoding=UTF-8
#spring.thymeleaf