首页 > 解决方案 > 如何在 HTML 表中重复数据库中的每个项目?

问题描述

我有这张表,其中第一项显示正常,但在第二次循环迭代中,该表以错误的方式显示:

我正在使用 ThymLeaf 作为前端!

<table>
    <tr class="row">
        <th class="tableHeader">Nombre</th>
        <th class="tableHeader">IP</th>
        <th class="tableHeaders">Sistema Operativo</th>
        <th class="tableHeaders">Notas</th>
    </tr>
    <tr class="row">
        <td id="datacenterName" th:each="dc : ${datacenterFisicHosts}" th:text="${dc.name}"></td>
        <td id="datacenterIp" th:each="dc : ${datacenterFisicHosts}" th:text="${dc.ip}"></td>
        <td id="datacenterOS" th:each="dc : ${datacenterFisicHosts}" th:text="${dc.operatingSystem}"></td>
        <td id="datacenterNotes" th:each="dc : ${datacenterFisicHosts}" th:text="${dc.notes}"></td>
    </tr>
</table>

在此处输入图像描述

我想th:each="dc : ${datacenterFisicHosts}"在相应的表头下对齐循环()中的每个项目。

标签: htmlcsshtml-tablethymeleaf

解决方案


推荐阅读