1、修改pom文件,添加依賴
1 <dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-thymeleaf</artifactId> 4 </dependency> 5 6 <dependency> 7 <groupId>nekohtml</groupId> 8 <artifactId>nekohtml</artifactId> 9 <version>1.9.6.2</version> 10 </dependency>
說明:使用springboot的thymeleaf模板時默認會對HTML進行嚴格的檢查,導致當你的標簽沒有閉合時就會通不過。nekohtml這個依賴可以解決這一問題。
2、簡單配置一下:
spring.thymeleaf.cache=false
spring.thymeleaf.mode = LEGACYHTML5
說明:
第一行配置是清除緩存,實現熱部署。也就是修改了html后不用重啟,刷新頁面就能看到效果。不過這兒特別強調一下,修改完html后一定要ctrl+f9重新build一下。再回到瀏覽器刷新,就能看到效果了,就這個花了我一個小時去找答案。
第二行配置是回避HTML進行嚴格的檢查的配置,當然你需要提前引入nekohtml依賴。
注意:引入
Thymeleaf
依賴后,可以不用在application.properties里配置,默認會在resource.templates里找 。html的頁面
原地址: https://blog.csdn.net/qq_22212003/article/details/80329896
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.6.2</version>
</dependency>
