IDEA+Springboot 踩过的坑之一模板引用时~{::title},~{::link},~{::script}或~{},~{},~{}

1.thymeleaf 模板,既然叫模板,那么我们使用的html也应该重新定义好。
标准的common.html

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title th:replace="${title}">ZSET common template of html</title>
<!-- Common styles and scripts -->
<link rel="shortcut icon" href="/springboot/favicon.ico"  th:href="@{/favicon.ico}"/>
<link rel="bookmark" href="/springboot/favicon.ico" th:href="@{/favicon.ico}"/>
<!-- Bootstrap -->
<link rel="stylesheet" th:href="@{/css/bootstrap/bootstrap.min.css}" />
<script type="text/javascript" th:src="@{/js/jquery/jquery-3.3.1.min.js}"></script>
<script type="text/javascript" th:src="@{/js/bootstrap/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/js/bootstrap/bootstrap-paginator.js}"></script>
<script type="text/javascript" th:src="@{/js/layer/layer.js}"></script>

<!--/* Per-page placeholder for additional links */-->
<th:block th:replace="${links}" />
<th:block th:replace="${scripts}" />
其它html使用它:main.html th:replace="/common/common :: common_header(~{::title},~{::link},~{::script})">xxx||成本管理系统

关键点:如果还有其它的引用时,{::title},{::link},{::script}),此三项才注明,否则应该写成这样:{},{},{};
否则会报thymeleaf 解析误!


版权声明:本文为hothome99原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。