java - 如何使用 thymleaf 并排显示表格?
问题描述
私人 int accno; 私人名单原因;
想要显示第一个(accno 和原因)左侧和第二个右侧,第三个左侧和第四个右侧....
示例代码不起作用
<table>
<tr th:each="cust: ${customer}">
<td th:text="${cust.accno}" />
<td th:text="${cust.reasons}" />
</tr>
</table>
预期输出附加截图
解决方案
我现在没有IDE,但我希望我的代码可以帮助你:
<table>
<tr th:each="cust, iter: ${customer}" th:if="${iter.even}" >
<td th:text="${cust[iter.index].accno}" />
<td th:text="${cust[iter.index].reasons}" />
<td th:text="${cust[iter.index+1].accno}" />
<td th:text="${cust[iter.index+1].reasons}" />
</tr>
</table>