【发布时间】:2019-10-28 00:21:11
【问题描述】:
我是 Thymeleaf 的新手,正在尝试在 Themeleaf 模板上创建一个动态表格。
我该怎么做..??
我一直在谷歌搜索,但没有得到任何正确的答案。问题是我无法迭代 List>。我可以有任意数量的列,列名可以是任何东西。
<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>
我需要动态设置值,因为如果查询结果会不断变化。现在列名是硬编码的,并且值也通过 row.getId 得到如果没有 Id,它可能是行中的任何东西我应该使用什么而不是..?示例行。。 rows 作为 List> 获得。
提前致谢。
【问题讨论】:
标签: spring-boot model-view-controller thymeleaf