SpringBoot-Thymeleaf
- 在application.yml中配置thymeleaf
spring:
thymeleaf:
cache: false
mode: LEGACYHTML5
encoding: UTF-8
servlet:
content-type: text/html
- 在pom.xml增加依赖包为了html更标准化(一定要符合w3c标准),可以提供非严格支持
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
在页面(index.html)修改htmml标签引入thymeleaf
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">