springboot项目引入thymeleaf模板时,默认thymeleaf模板对html5标签是严格检查的。要实现非严格检查

1. 在项目中加NekoHTML库

在Maven中添加依赖

  1. <dependency>  
  2.     <groupId>net.sourceforge.nekohtml</groupId>  
  3.     <artifactId>nekohtml</artifactId>  
  4.     <version>1.9.22</version>  
  5. </dependency>  

2.更改thymeleaf设置

在配置文件application.properties中,对thymeleaf模板设置。

LEGACYHTML5需要搭配NekoHTML库才可用,实现thymeleaf非严格检查。

  1. #thymeleaf  
  2. spring.thymeleaf.encoding=UTF-8  
  3. spring.thymeleaf.suffix=.html  
  4. #默认严格检查  
  5. #spring.thymeleaf.mode=HTML5  
  6. #非严格检查  
  7. spring.thymeleaf.mode=LEGACYHTML5  
posted on 2018-04-23 17:13  YKKKK  阅读(143)  评论(0编辑  收藏  举报