小编Raj*_*Raj的帖子

如何在 Thymeleaf 中创建动态表..?

我是 Thymeleaf 的新手,尝试在 Themeleaf 模板上创建动态表。

我该怎么做..??

我一直在谷歌搜索我没有得到任何正确的答案。问题是我无法迭代 List< Map< String,Object >>。我可以有任意数量的列,列名称可以是任何东西。

<tr class="headings">
 <th class="column-title">ID</th>
 <th class="column-title">Name</th>
 <th class="column-title">Salary</th>
 <th class="column-title">Status</th>  
 </tr>
</thead>
<tbody>
 <tr class="even pointer" th:each="row:${rows}" id = "tablerow">
 <td class=" " th:text="${row.getId()}">Id</td>
 <td class=" " th:text="${row.getName()}">Name</td>
 <td class=" " th:utext="${row.getSalary()}">Salary</td>
 <td class=" " th:text="${row.getStatus()}">Active</td>
 </tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)

我需要动态设置值,因为结果查询是否会不断变化。现在列名是硬编码的,值也是通过row.getId获取的,如果没有 Id,它可以是行中的任何内容,我应该使用什么比..?示例行。<>。rows 通过 List<Map<String, Object>> 获得。

提前致谢。

model-view-controller thymeleaf spring-boot

4
推荐指数
1
解决办法
1万
查看次数