事件背景:

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

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

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

原因:

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

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

解决方案:

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://blog.csdn.net/zpengf/article/details/80096346

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-09-26
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2021-11-03
猜你喜欢
  • 2021-12-25
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
  • 2021-06-06
相关资源
相似解决方案