在模板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
(如预期的那样)
答案 0 :(得分:1)
属性th:replace
需要模板表达式,而不是文本变量。如果将其更改为:
<title th:text="${title}">Default title</title>