An error happened during template parsing (template: “class path resource [templates/index.html]“)

1,错误

An error happened during template parsing (template: “class path resource [templates/index.html]”)

2.代码修改

我自己的Java代码是正确的,只是视图层的问题!
下面就是我一开始的部分前端代码:

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head(~{::title})">

然后运行就报了500错误:控制台为:

2021-07-05 21:02:47.331 ERROR 13076 --- [nio-8080-exec-3] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8080-exec-3] Exception processing template "index": An error happened during template parsing (template: "class path resource [templates/index.html]" - line 579, col 60)

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]" - line 579, col 60)

然后也是百度了好一会儿才解决的,总之就是坚信自己的Java服务层代码没错!
解决方法:
就是把xml namespace(命名空间)代码删除:
删除之后的代码为:

<!DOCTYPE html>
<html lang="en">
<head replace="_fragments :: head(~{::title})">

记得把带有th:的代码都删除掉,之后要用的时候再添加条件再加上

3.总结

记得出现该错误的时候,如果你对前端知识不太了解,坚信自己的Java服务层代码无误的情况下那么请相信自己,欸,也许我是对自己的Java技术不太自信吧(的确技术页不好,哈哈)!

坚信自己就是静态资源导入的代码出错,和Java代码不匹配。

我自己就是遇见这个问题浪费了好多时间,希望对大家有所帮助!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值