1. 程式人生 > >springboot的thymeleaf模板問題springboot的thymeleaf模板問題

springboot的thymeleaf模板問題springboot的thymeleaf模板問題

fix pid source pen html5標簽 需要 嚴格 thymeleaf cef

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

springboot的thymeleaf模板問題springboot的thymeleaf模板問題