static {
pokals.add(new Pokal("1", 1, "Deutscher Meister"));
pokals.add(new Pokal("2", 5, "Deutscher Pokalsieger"));
pokals.add(new Pokal("3", 1, "Uefa Cup Sieger"));
pokals.add(new Pokal("4", 1, "Deutscher Zweitligameister"));
}
@RequestMapping(value = "/pokalList/{ID}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public void deletepokal(@PathVariable("Id") String Id) {
pokals.remove(Id);
}
答案 0 :(得分:0)
您的代码看起来还不错。
如果我尝试打开网页,则表明不允许使用这些方法(错误405)。谁能说出错误在哪里?谢谢 提前!
但是,从您在问题中的上述陈述来看,您似乎暗示您试图通过浏览器将端点作为网页访问?
浏览器发送GET请求,该请求被禁止,因为期望DELETE,因此状态为405。
尝试使用CURL发送DELETE请求:
curl -iv -X "DELETE" http://localhost:8080/pokalList/1
或使用邮递员之类的客户端