<html>
<head>
<title><sitemesh:write property='title'/></title>
<sitemesh:write property='head'/>
</head>
<body>
<p th:text="${message}">message</p>
<sitemesh:write property='body'/>
</body>
</html>
hello.html的
<html>
<head>
<title>test</title>
</head>
<body>
Hello world
</body>
</html>
返回结果是
<html>
<head>
<title>test</title>
</head>
<body>
<p th:text="${message}">message</p>
Hello world
</body>
</html>
&#34;消息&#34;没有被百里香叶解析。这是一个错误吗?
答案 0 :(得分:0)
假设您正确配置了模板解析器和模板引擎。从您分享的HTML中,您尚未定义th
标准方言定义。
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title><sitemesh:write property='title'/></title>
<sitemesh:write property='head'/>
</head>
<body>
<p th:text="${message}">message</p>
<sitemesh:write property='body'/>
</body>
</html>