添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
application.yml配置thymeleaf相关属性
spring:
thymeleaf:
#开发时设为false关闭缓存,便于调试,生产环境为true
cache: false
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
content-type: text/html
#声明thymeleaf使用非严格的html
mode: LEGACYHTML5