一、概述
最近在springboot项目引入thymeleaf模板时,使用非严格标签时,运行会报错。默认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
最后
以上就是洁净大叔最近收集整理的关于thymeleaf模板实现html5标签的非严格检查的全部内容,更多相关thymeleaf模板实现html5标签内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复