Spring boot 在Thymeleaf中打印值
我想在Thymeleaf中的迭代中传递一个整数值。我们如何在thymeleaf实现这一点Spring boot 在Thymeleaf中打印值,spring-boot,thymeleaf,Spring Boot,Thymeleaf,我想在Thymeleaf中的迭代中传递一个整数值。我们如何在thymeleaf实现这一点 <tr th:each="client : ${clients}"> <td th:text="${client.name}"></td> <td th:text="${client.contactPersonName}"></td>
<tr th:each="client : ${clients}">
<td th:text="${client.name}"></td>
<td th:text="${client.contactPersonName}"></td>
<td th:text="${client.phone}"></td>
<td th:text="${client.email}"></td>
<td th:text="${client.databases.name}"></td>
<td onclick="deleteConfirmation(${client.id}">Delete</td>
</tr>
删除
这更像是我们如何在html上打印任何值
<p>${anyVariableViaController}</p>
${anyVariableViaController}
变量有一个索引和一个计数(分别从0和1开始)
删除
这是否回答了您的问题?
<tr th:each="client, status : ${clients}">
<!-- starting from 0 -->
<td th:text="${status.count}" />
<!-- starting from 1 -->
<td th:text="${status.index}" />
<td th:text="${client.name}"></td>
<td th:text="${client.contactPersonName}"></td>
<td th:text="${client.phone}"></td>
<td th:text="${client.email}"></td>
<td th:text="${client.databases.name}"></td>
<td onclick="deleteConfirmation(${client.id}">Delete</td>
</tr>