如何在表中使用thymeleaf迭代(循环)?

问题描述 投票:0回答:1
html frontend thymeleaf
1个回答
0
投票

为此,出现了 iterStat 这样的东西。是一种用于跟踪迭代状态的有用机制:状态变量。 这展示了如何输出 5 个项目,然后移至新行。

    <table>
    <tr th:each="product, iterStat : ${data}">
        <td>
            <input type="checkbox" name="productCode" th:value="${product.productCode}" th:text="${product.productName}" />
        </td>
        <th:block th:if="${iterStat.count % 5 == 4 and !iterStat.last}">
            </tr><tr>
        </th:block>
    </tr>
</table>
© www.soinside.com 2019 - 2024. All rights reserved.