我有一张表格用于将一个对象添加到另一个对象并从另一个对象中删除一个对象。删除时请求方法GET不支持
这是我的控制器:
@Controller
@RequestMapping("/proj/{pid}/coupling/{r1}")
public class CouplingController {
@RequestMapping(method = RequestMethod.GET)
public String getAllCouplings(){
return "riskCoupling";
}
@RequestMapping(value = "/{r1}", method = RequestMethod.POST)
public String saveCoupling(){
return "/projects";
}
@RequestMapping(value = "/{r2}", method = RequestMethod.DELETE)
public String removeCoupling(){
return "/projects";
}
这是我Thymeleaf观点
<td>
<form action = "#" th:action="@{/proj/{pid}/coupling/{r1}/{r2} (pid=${projectID},r1=${r1ID},r2=${r2.id})}" method = "post">
<input type="submit" name="Couple" value="Couple" class="btn btn-info" />
</form>
</td>
<td">
<form action = "#" th:action="@{/proj/{pid}/coupling/{r1}/{r2} (pid=${projectID},r1=${r1ID},r2=${r2.id})}" method = "delete">
<input type="submit" name="RemoveCoupling" value="RemoveCoupling" class="btn btn-info" />
</form>
</td>
当我去到URL “/凸出/ {PID} /偶/ {R 1}” 我得到总览如此GET的工作。 当我按下夫妇按钮它的作品。所以邮政工作。 当我按RemoveCoupling按钮,我得到错误: 请求方法“Get”不支持。
我真的不知道为什么我会得到这个错误。
可能你有同样的问题:https://stackoverflow.com/questions/ 13629653 /使用看跌和 - 删除 - 方法合弹簧-MVC –