我使用类型为"DELETE"的jquery ajax发送请求。 在服务器端,我有approprite句柄方法,如下所示:
@RequestMapping(value ="/{id}", method = RequestMethod.DELETE)
public String delete(@RequestParam("hotel") String hotelCode, @PathVariable Long id, Model model){
//delete operation
return"redirect:/HotelTaxesAndCharges?hotel="+hotelCode;
}
我想在删除后重定向我的调用的方法如下所示
@RequestMapping(method = RequestMethod.GET)
public String getAll(@RequestParam("hotel") String hotelCode, Model model){
//logic
return 'getAll';
}
因此,当我在执行期间调用delete方法时,我收到错误"您可以仅使用GET PUT或HEAD方法重定向到JSP"。 我找到了使用HiddenHttpMethodFilter的解决方案,但结果代码看起来有点乱,我需要使用POST发送请求并添加其他参数(_method)以使用自定义请求类型进行请求。
所以我的问题是DELETE / REDIRECT / GET转换的任何其他解决方案。
抱歉不好的英语