我的控制器里有这样的方法
@Controller
@RequestMapping ("/admin/users")
public class AdminUserController {
..
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public @ResponseBody boolean deleteUser(@PathVariable("id") int id,
HttpServletResponse response) {
..
}
..
}这是ajax请求
$.ajax({
url: '/admin/users/'+id,
type: 'delete',
success: function(data){
console.log(data);
},
error: function(e){
console.log(e);
}
});当我发送这个请求时,它失败了,我得到405。当我查看响应头时,我看到了这个Allow:"GET"。
好的。我将ajax请求'delete‘改为' get’,然后我得到响应Allow:"DELETE"。
它能是什么?
发布于 2015-12-13 21:32:46
我认为您的服务器安全配置不允许删除操作,并且基本上是头文件:
ALLOW: GET建议您尝试GET请求,但因为您指定了
method = RequestMethod.DELETE拒绝该方法调用的Spring。
您应该将method = RequestMethod.DELETE更改为method = RequestMethod.GET并发出HTTP请求。
如果这有帮助的话请告诉我。
https://stackoverflow.com/questions/34230086
复制相似问题