最近在springboot項目引入thymeleaf模板時,極速ssc源碼出售【企鵝21717-93408】使用非嚴格標籤時,運行會報錯。默認thymeleaf模板對html5標籤是嚴格檢查的。
二、在項目中加NekoHTML庫
在Maven中添加依賴
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
三、更改thymeleaf設置
在配置文件application.properties中,對thymeleaf模板設置。
LEGACYHTML5需要搭配NekoHTML庫纔可用,實現thymeleaf非嚴格檢查。
#thymeleaf
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.suffix=.html
#默認嚴格檢查
#spring.thymeleaf.mode=HTML5
#非嚴格檢查
spring.thymeleaf.mode=LEGACYHTML5