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模板引擎解析错误。