在模板header
中我有
<head th:fragment="common_header(title)">
<title th:replace="${title}">Default title</title>
<meta charset="utf-8" />
...
</head>
我尝试在参数中使用文字:
<head th:replace="~{header::common_header(title='This should be real title')}">
<title>Just for template's sake...</title>
<meta charset="utf-8" />
...
</head>
但是我得到的只是
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "This should be real title", template might not exist or might not be accessible by any of the configured Template Resolvers (template: "header" - line 4, col 9)
我在做什么错?使用_
(无操作令牌(的 Default title
产量(如预期(
属性th:replace
期望模板表达式,而不是文本变量。如果将其更改为:
<title th:text="${title}">Default title</title>