我正在学习本教程:http://www.thymeleaf.org/doc/layouts.html(获得Thymeleaf布局方言部分).在那里你可以找到一个例子:
<!DOCTYPE html>
<html>
<head>
<!--/* Each token will be replaced by their respective titles in the resulting page. */-->
<title layout:title-pattern="$DECORATOR_TITLE - $CONTENT_TITLE">Task List</title>
...
</head>
<body>
<!--/* Standard layout can be mixed with Layout Dialect */-->
<div th:replace="fragments/header :: header">
...
</div>
<div class="container">
<div layout:fragment="content">
...
</div>
<div th:replace="fragments/footer :: footer">© 2014 The Static Templates</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
th:replace在上面的示例中,页脚和标题被标记替换,而在布局文件中<head>有<title>标记.
基本上,我想用整个<head>标签替换th:replace.因此,我有:
我的布局文件:
<!DOCTYPE html>
<html> …Run Code Online (Sandbox Code Playgroud)