我有一个动态生成的表,每次刷新页面都会插入一行新数据。我如何限制表格最多只显示 7 个表格行,一旦达到 7 个。用数据更新表格现有表格行而不是添加新行。我的应用程序包括前端的 thymeleaf,后端的 java/springboot。
我在这个脚本中使用 thymeleaf 来自动生成我的代码。
<table th:object="${showbudata}">
<thead>
<tr>
<th> Date </th>
<th> Status </th>
<th> HostName </th>
<th> Implement Version</th>
</tr>
</thead>
<tbody>
<tr th:each="t: ${showbudata}" th:if="${server.host == t.host}">
<td th:text="${t.date}" />
<td th:text="${t.Status}" />
<td th:text="${t.host}" />
<td th:text="${t.version}" />
</tr>
</tbody>
</table>
最佳答案
您需要为您的数据实现命名分页
。您可能有兴趣查看 Thymeleaf Spring Data Dialect .
关于javascript - 如何对动态生成的表行设置限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41701020/