1目录
2. header代码 footer代码
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="header(title)">
<meta charset="UTF-8">
<link rel="stylesheet" th:href="@{/css/main/main.css}" />
<title th:replace="${title}"></title>
</head>
<div th:fragment="footer">
<script th:src="@{/js/test.js}"></script>
</body>
</html>
</div>
4.index代码 其中~{::title}指的是获取下面<title>的值 便于多页面复用
<!--引入头部head.html-->
<head class="panelBar" th:replace="/layout/header::header(~{::title})">
<title>首页</title>
</head>
<div class="main-page">
WELCOME
<a class="button" href="/toLogin">登录</a>
<a class="button" href="/toRegister">注册</a>
</div>
<head class="panelBar" th:replace="/layout/footer::footer"></head>