错误:org.xml.sax.SAXParseException: 元素类型 xx 必须由匹配的结束标记 /xx问题

事件背景:

今天就碰到了这样的问题,

org.xml.sax.SAXParseException: 元素类型 "head" 必须由匹配的结束标记 "</head>

我本地编译的时候报错,上面报错,起初 我以为是我画的html页面报错呢,一个个标签查呀,查了一个多小时没结果

原因:

spring-boot-starter-thymeleaf对html5默认校验要求高。一言不合就报错如下:

解决方案:

1、在pom.xml中添加依赖

<!--启用不严格检查html-->

<dependency>
   <groupId>net.sourceforge.nekohtml</groupId>
   <artifactId>nekohtml</artifactId>
   <version>1.9.22</version>
</dependency>

2、在 application.properties

2.1、关闭缓存

spring.thymeleaf.cache=false

2.2、修改

spring.thymeleaf.mode=LEGACYHTML5

原文:https://www.cnblogs.com/longronglang/p/10009942.html

发布了27 篇原创文章 · 获赞 9 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/sofeware333/article/details/92801111