一、导入依赖:
<!--thymeleaf页面加载-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
二、设置配置:
application.properties:
spring.mvc.static-path-pattern=/static/**
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.cache=false# 开发禁用缓存
spring.thymeleaf.prefix=classpath:/templates/# 访问template下的html文件需要配置模板,映射
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.suffix=.html
application.yml:
spring:
thymeleaf:
mode: HTML5
encoding: UTF-8
prefix:
# 访问template下的html文件需要配置模板,映射
classpath:/templates/
# 开发禁用缓存
cache: false
servlet:
content-type: text/html
记录配置,以作后用。