1.提取公共页面
- 给提取部分取名
th:fragment="topbar"
- 添加提取部分
<!--引用dashboard的侧边导航栏-->
<div th:insert="~{comment/comment::topbar(active='list.html')}"></div>
- 如果要传递参数
<!--传递参数-->
<div th:insert="~{comment/comment::sidebar(active='dashboard.html')}"></div>
<!--接收参数-->
<a th:class="${active=='dashboard.html'?'nav-link active':'nav-link'}">
2列表循环展示
<thead>
<tr>
<th>id</th>
<th>lastName</th>
<th>email</th>
<th>gender</th>
<th>department</th>
<th>birth</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr th:each="emp:${empS}">
<td th:text="${emp.getId()}"></td>
<td>[[${emp.getLastName()}]]</td>
<td th:text="${emp.getEmail()}"></td>
<td th:text="${emp.getGender()==0?'女':'男'}"></td>
<td th:text="${emp.getDepartment().getDepartmentName()}"></td>
<td th:text="${#dates.format(emp.getBirth(),'yyyy-MM-dd HH:mm:ss')}"></td>
<td>
<button class="btn btn-sm btn-primary">编辑</button>
<button class="btn btn-sm btn-danger">删除</button>
</td>
</tr>
</tbody>