我在使用thmyleaf将表格单元格值发送到spring控制器方面颇费力气。我想提交当前的行单元格“ id”,我需要将URL与thymeleaf id字段连接起来,但是我似乎无法正确处理。
我在做什么错?这是我当前的代码(简体):
<table>
<thead>
<tr>
<th style="text-align: center">Text</th>
<th style="text-align: center">Id</th>
</tr>
</thead>
<tbody>
<tr th:if="${results.empty}">
<td colspan="2">No entries</td>
</tr>
<td th:text="${result.text}"></td>
<td>
<button type="submit" th:action="@{/entry/delete} + '?id=' + ${result.id}" method="get">Delete</button>
</td>
</tr>
</tbody>
</table>
发现问题,是语法问题。解决方案:
<a th:href="@{/entry/delete(id=${result.id})}">Delete</a>