📅  最后修改于: 2023-12-03 14:43:01.365000             🧑  作者: Mango
TymeLeaf是一款Java模板引擎,可用于构建Web应用程序。它支持MVC架构并且是一个强大的视图技术。应用程序开发人员可以使用TymeLeaf来处理HTML/XML视图。
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Employee Management</title>
<link rel="stylesheet" href="../css/style.css" />
</head>
<body>
<h1>Employee Management</h1>
<table>
<tr>
<th>Employee ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Phone</th>
</tr>
<tr th:each="employee : ${employees}">
<td th:text="${employee.id}" />
<td th:text="${employee.firstName}" />
<td th:text="${employee.lastName}" />
<td th:text="${employee.email}" />
<td th:text="${employee.phone}" />
</tr>
</table>
<a href="/employees/new">Add New</a>
</body>
</html>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<link rel="stylesheet" href="../css/style.css" />
<title>Insert title here</title>
</head>
<body>
<header th:fragment="header">
<h1>Header Title</h1>
<nav>
<ul>
<li><a th:href="@{/home}">Home</a></li>
<li><a th:href="@{/about}">About</a></li>
<li><a th:href="@{/contact}">Contact</a></li>
</ul>
</nav>
</header>
</body>
</html>
<footer th:fragment="footer">
<p>This is the footer.</p>
</footer>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<link rel="stylesheet" href="../css/style.css" />
<title>Insert title here</title>
</head>
<body>
<div th:include="layout :: header"></div>
<h1>Hello World!</h1>
<div th:include="layout :: footer"></div>
</body>
</html>