thymeleaf引html页面时报找不到页面和页面解析错误

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: “ServletContext resource [/WEB-INF/templates/d.html]” - line 10, col 6)

Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/templates/xxx.html]

编程不细心真不行。有时就是因为粘贴代码时不注意,导致前后代码不一样,出了错误,找半天。上面又是报语法错误,又是报文件找不到了。

昨天运行都一切正常。
昨天的html头部引用的约束是:xmlns=“http://www.w3.org/1999/xhtml”
今天把它粘贴到了一个页面。

而主页是:xmlns:th=“http://www.thymeleaf.org”
两个统一一下:统一成xmlns:th=“http://www.thymeleaf.org”,
然后我的文件结构
在这里插入图片描述
在c中引入d,之前这样还ok的,今天就报错找不到文件

<div th:include="d"></div>

更改成这样子就正确了

<div th:include="admin/d"></div>

贴一下b.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div th:fragment="d">
<h1 th:text="${b}"></h1>
<h1 th:text="${a}"></h1>
</div>
</body>
</html>

c.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div th:fragment="d">
<h1 th:text="${b}"></h1>
<h1 th:text="${a}"></h1>
</div>
</body>
</html>

尤其要注意thymeleaf约束标签的地址,别引入错了,否则很容易报thymeleaf模板引擎解析错误。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值