Thymeleaf 使用指南

一、常用标签

th:block 

不显示

th:include

替换内容到引入的文件

二、关联css与js

href 和 src : 用于直接预览页面(在不启动服务器的情况下)

th:href 和 th:src 启动服务器时使用

<link rel="stylesheet" href="../static/assets/plug-in/antd2.2.2/antd.min.css" th:href="@{~/assets/plug-in/antd2.2.2/antd.min.css}"/>
<script src="../static/assets/plug-in/vue3.1.5/vue.global.js" th:src="@{assets/plug-in/vue3.1.5/vue.global.js}"></script>
<script src="../static/assets/plug-in/antd2.2.2/antd.min.js" th:src="@{assets/plug-in/antd2.2.2/antd.min.js}"></script>
<script src="../static/assets/plug-in/moment/moment.js" th:src="@{assets/assets/plug-in/moment/moment.js}"></script>
<script src="../static/assets/plug-in/lodash1.8.3/lodash.js" th:src="@{assets/plug-in/lodash1.8.3/lodash.js}"></script>
<script src="../static/assets/base/common.js" th:src="@{assets/base/common.js}"></script>

 二、公共内容引用

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:fragment=header>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="../static/assets/plug-in/antd2.2.2/antd.min.css" rel="stylesheet"/>
</head>


<body>

</body>
<div th:fragment="footer">
</div>
</html>
原文地址:https://www.cnblogs.com/ghostnet/p/15102820.html