平日使用thymeleaf时,发现使用要求非常严格,比如<input type="text" />单标签结尾便会报错,只有这样<input type="text" > </input>才可以。
为了解决这种严格的使用规则,可以添加如下依赖:
<!--thymeleaf的依赖包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--为了解决thymeleaf模板中,对html标签要求太严格的问题!-->
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
本文介绍了解决Thymeleaf在处理HTML标签时过于严格的问题,通过添加nekohtml依赖,使Thymeleaf能更灵活地解析单标签,如<inputtype=text/>,避免了必须使用完整开闭标签的限制。
21万+

被折叠的 条评论
为什么被折叠?



