带有来自 thymeleaf 的路径变量的多个请求映射值
Multiple requestmapping value with path variables from thymeleaf
我必须像这样在 a th:href
中将两个数据从 thymeleaf
发送到 controller
:
<table id="itemTable" class="deneme">
<tbody>
<tr th:each="item : ${list.items}">
<td>
<p th:text="${item.content}"/>
<a th:href="@{/deleteItem/{listId}(listId=${list.id})/{itemId}(itemId=${item.id})}">
<span>Delete</span>
</a>
</td>
</tr>
</tbody>
</table>
控制器是:
@RequestMapping("/deleteItem/{listId}/{itemId}")
public String deleteItem(Model model, @PathVariable(value = "listId") Integer listId, @PathVariable(value = "itemId") int itemId) {
...
return "list";
}
itemId
是真实值,但 listId
是 {listId}(listId=${toDoList.id})
到底是什么问题?请帮助我!
多个参数的语法如下所示:
<a th:href="@{/deleteItem/{listId}/{itemId}(listId=${list.id},itemId=${item.id})}"><span>Delete</span></a>
我必须像这样在 a th:href
中将两个数据从 thymeleaf
发送到 controller
:
<table id="itemTable" class="deneme">
<tbody>
<tr th:each="item : ${list.items}">
<td>
<p th:text="${item.content}"/>
<a th:href="@{/deleteItem/{listId}(listId=${list.id})/{itemId}(itemId=${item.id})}">
<span>Delete</span>
</a>
</td>
</tr>
</tbody>
</table>
控制器是:
@RequestMapping("/deleteItem/{listId}/{itemId}")
public String deleteItem(Model model, @PathVariable(value = "listId") Integer listId, @PathVariable(value = "itemId") int itemId) {
...
return "list";
}
itemId
是真实值,但 listId
是 {listId}(listId=${toDoList.id})
到底是什么问题?请帮助我!
多个参数的语法如下所示:
<a th:href="@{/deleteItem/{listId}/{itemId}(listId=${list.id},itemId=${item.id})}"><span>Delete</span></a>