java Thymeleaf显示具有动态列数的表
我正在开发一个spring启动应用程序,使用thymeleaf作为我的模板引擎。在这种情况下,我需要显示一个可以在列的数量上变化的列表。这就是我目前的情况:
<table class="table table-hover" th:if="${d.hasRecords()}">
<thead>
<tr>
<th:block th:eacth="h : ${d.header}">
<th th:colspan="${d.header.length}" th:text="${h}">Header Field</th>
</th:block>
</tr>
</thead>
<tbody>
<tr th:each="record : ${d.records}">
<th:block th:each="field : ${record}">
<td th:text="${field}">Dataset Field</td>
</th:block>
</tr>
</tbody>
</table>
header
变量是一个标准字符串[]数组,records
对象是一个字符串数组列表。表格显示表格的主体,但不显示标题。唯一的区别(就我所见)是主体是嵌套循环,而标题不是。有人能帮我解释一下为什么标题不会出现吗。不,头数组不是空的或null
共 (0) 个答案