thymeleaf如何遍历数据

首先,在html开始标签内 的xmlns:th引入thymeleaf

 1 <html xmlns:th="http://www.thymeleaf.org">  

再使用each循环来进行遍历

1  <tbody>
2                     <tr th:each="user : ${users}">  
3                         <td th:text="${user.name}"></td>
4                         <td th:text="${user.email}"></td>
5                         <td><a th:href="@{/edit/{id}(id=${user.id})}">修改</a></td>
6                         <td><a th:href="@{/delete/{id}(id=${user.id})}">删除</a></td>
7                     </tr>
8                 </tbody>

 

posted @ 2019-06-27 23:44  JackSon~鹤  阅读(6488)  评论(0编辑  收藏  举报