SpringBoot Thymeleaf : Exception parsing document: template=“index1”, line 6 - column 3

环境:IDEA、maven、spring、Thymeleaf

报错页面:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu May 28 17:08:33 CST 2020

There was an unexpected error (type=Internal Server Error, status=500).

Exception parsing document: template=“index1”, line 6 - column 3

在这里插入图片描述

查看控制台

提示:

org.xml.sax.SAXParseException: 元素类型 “meta” 必须由匹配的结束标记 “</meta>” 终止。

在这里插入图片描述

这个其实是thymeleaf语法检查的问题,可以选择直接按照提示修改语法,也可以配置文件,直接一劳永逸去掉严格检查。

选择修改语法:

就不写详细过程了,缺啥写啥,按照提示直接加</meta>和其他的关闭标签就可。

选择配置:

application.yml

新建yml文件在resource目录下

在这里插入图片描述

文件中加入以下配置:

spring:
  thymeleaf:
    mode: LEGACYHTML5  # 不进未关闭标签检查,需配合nekohtml使用
pom.xml

添加neko和thymeleaf版本号:

    <dependencies>
		<!--我的neko配置, 用于解决thymeleaf报错问题-->
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
            <version>${nekohtml.version}</version>
        </dependency>
    </dependencies>

<!--...-->

	<properties>
        <!--配置thymeleaf-->
        <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
        <thymeleaf-layout-dialect.version>2.0.5</thymeleaf-layout-dialect.version>
    </properties>
刷新maven

如果在idea里面使用,一定记得刷一下maven!!!

如图那个小m图标,快捷键Ctrl+Shift+O

在这里插入图片描述

重新运行项目,完成

用maven来build之后,重启一下服务器,应该不会报错了。

参考链接
spring官方配置文档
spring-boot-starter-thymeleaf对没有结束符的HTML5标签解析出错
springboot 使用thymeleaf 模板引擎时报错org.xml.sax.SAXParseException: 元素类型 “link” 必须由匹配的结束标记 “” 终止

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值