hymeleaf模板实现html5标签的非严格检查

一、概述

最近在springboot项目引入thymeleaf模板时,使用非严格标签时,运行会报错。默认thymeleaf模板对html5标签是严格检查的。

二、在项目中加NekoHTML库

在Maven中添加依赖

net.sourceforge.nekohtml nekohtml 1.9.22

三、更改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

https://km.pzi.cn/

猜你喜欢

转载自blog.csdn.net/a15732111571/article/details/88641088