【问题标题】:AngularJS Spring CRUD delete 405 Request method 'DELETE' not supportedAngularJS Spring CRUD删除405请求方法'DELETE'不支持
【发布时间】:2017-10-28 22:41:17
【问题描述】:

我正在使用 AngularJS 和 Spring 制作简单的 CRUD 应用程序。 当我进行 DELETE 调用时,它会发送此错误:

Request method 'DELETE' not supported

角函数

$scope.delete = function(item){
    $http({
        method:"DELETE",
        url:"/task/"+item.id,            
    }).then(function() {
        for(var i = 0; i < $scope.tasks.length; i++){
            if(item.id==$scope.tasks[i].id){
                $scope.tasks.splice(i, 1);
            }
        }
    });

弹簧删除控制器

`@DeleteMapping("/task/{id}")
    @ResponseBody
    public  HttpStatus delete(@PathVariable String id){
        System.out.println("Call 1");
        taskService.delete(id);
        System.out.println("Call 2");
        return HttpStatus.OK;
    }`

【问题讨论】:

  • @DeleteMapping("/task/{id]")更改为@DeleteMapping("/task/{id}")
  • 哦,打错了
  • 请为 Spring 启用调试日志,并告诉我们您的 delete 处理程序方法是否已注册。

标签: java angularjs spring spring-mvc


【解决方案1】:

我认为您应该添加路径变量名称,例如@PathVariable('id') String id

【讨论】:

    猜你喜欢
    • 2015-06-24
    • 1970-01-01
    • 2014-06-10
    • 2017-07-01
    • 1970-01-01
    • 2014-06-14
    • 2019-11-07
    • 2020-08-12
    • 2020-07-24
    相关资源
    最近更新 更多