pom.xml引入依賴html
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
application.properties中配置:spring
##去除thymeleaf的html嚴格校驗 spring.thymeleaf.mode=LEGACYHTML5 #設定thymeleaf文件路徑 默認爲src/main/resources/templates spring.freemarker.template-loader-path=classpath:/templates
模版html頁面中,也是須要引入thymeleaf:後端
<html xmlns:th="http://www.thymeleaf.org">
爲了解決html嚴格校驗報錯的問題,能夠在pom.xml增添依賴nekohtmlspringboot
<dependency> <groupId>net.sourceforge.nekohtml</groupId> <artifactId>nekohtml</artifactId> <version>1.9.15</version> </dependency>