我有一張表格用於將一個對象添加到另一個對象並從另一個對象中刪除一個對象。刪除時請求方法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 –