springboot03-thymeleaf详细使用

th:each遍历数组

    @RequestMapping("/success")
    public String success(Model model, Map<String,Object> map){
        map.put("users", Arrays.asList(new User("寇春雷",22),new User("寇雨泽",8),new User("张三",22)));
        return "success";
    }
<table>
  <tr th:each="user: ${users}">
    <td th:text="${user.name}"></td>
    <!--或者这样写-->
    <td>[[${user.age}]]</td>
  </tr>
</table>
posted @ 2022-04-04 17:25  超级氯化钾  阅读(42)  评论(0)    收藏  举报