Rest 如何删除Thymeleaf上的对象:每次迭代都向控制器传递一个ID?

Rest 如何删除Thymeleaf上的对象:每次迭代都向控制器传递一个ID?,rest,controller,each,thymeleaf,Rest,Controller,Each,Thymeleaf,我的控制器: @GetMapping("/deletesocio/{id}") public String delSocios(@PathVariable Long id){ socioSer.borrar(socioService.buscarPorId(id)); return "redirect:/webapp/socios"; } 我的HTML <tr th:each="soc : ${list}"> <td th:text="${soc.id

我的控制器:

@GetMapping("/deletesocio/{id}")
public String delSocios(@PathVariable Long id){
    socioSer.borrar(socioService.buscarPorId(id));
    return "redirect:/webapp/socios";
}
我的HTML

<tr th:each="soc : ${list}">
    <td th:text="${soc.idSocio}">#</td>
    <td th:text="${soc.nombreSocio}">Nombre</td>
    <td class="button778"><button type="button" 
    th:href="@{/webapp/delsocio/${soc.idSocio}}"></button></td>
</tr>

#
名义

我想通过点击这个按钮来删除这个对象,这个按钮将de id传递给控制器(好吧,这就是想法),有人能帮我吗??非常感谢您

本章共分为两部分

1) 您应该使用的url表达式是:
@{/webapp/delsocial/{id}(id=${soc.idSocio})}


2) 您可以将其设置为带有提交按钮的表单,也可以将常规链接设置为按钮样式。无论您选择哪种解决方案,都将决定您是否使用
th:action=“@{/webapp/delsoco/{id}(id=${soc.idSocio}”)或
th:href=“@{/webapp/delsoco/{id}(id=${soc.idSocio}”)

我想使用它而不使用表单。。。我应该在那个按钮上按一个方法吗?url必须带有th:href?控制器呢?这是getmaping?o也许是邮戳?我不知道为什么它还不能工作如果你想在没有表单的情况下完成它,那么就创建一个链接,并将其样式设置为一个按钮(我链接到的帖子展示了如何做到这一点)。在这种情况下,控制器应该是@GetMapping。谢谢,我不记得我需要一个链接来让按钮工作,这给了我6个小时xD