javascript - Request method 'PUT' not supported - Stack Overflow

I'm working with springboot angularsjs and restful.my rest controller@RequestMapping(value="

I'm working with springboot angularsjs and restful.

my rest controller

@RequestMapping(value="/updatestructure/{ch}",method = RequestMethod.PUT)
public @ResponseBody Structurenotification updateStructure(@PathVariable(value="ch") StructureNotificationDto ch) {
    return StructureNotif.update(ch);
}

the button

$scope.addstructure = function() {
      $http.put('/structure/updatestructure/', $scope.element);
};

But I get this problem :

o.s.web.servlet.PageNotFound: Request method 'PUT' not supported

I'm working with springboot angularsjs and restful.

my rest controller

@RequestMapping(value="/updatestructure/{ch}",method = RequestMethod.PUT)
public @ResponseBody Structurenotification updateStructure(@PathVariable(value="ch") StructureNotificationDto ch) {
    return StructureNotif.update(ch);
}

the button

$scope.addstructure = function() {
      $http.put('/structure/updatestructure/', $scope.element);
};

But I get this problem :

o.s.web.servlet.PageNotFound: Request method 'PUT' not supported

Share Improve this question edited Dec 1, 2015 at 19:20 r007 3041 gold badge2 silver badges17 bronze badges asked Apr 19, 2015 at 12:41 majed ben alimajed ben ali 311 silver badge8 bronze badges 1
  • I think this problem could be more related to Java than JavaScript – MDEV Commented Apr 19, 2015 at 13:20
Add a ment  | 

1 Answer 1

Reset to default 5

You have defined your {ch} variable as PathVariable, and you send it as Request Body. You Mapping accepts URL's like /structure/updatestructure/abc,/structure/updatestructure/efg, and values abc and efg would be than passed as strings. In this case your mapping should look like this.

@RequestMapping(value="/updatestructure/{ch}",method = RequestMethod.PUT)
public @ResponseBody Structurenotification updateStructure(@PathVariable String ch) {    
}

But, your are actualli going to send a JSON as request body(assuming from your angular $http.put(url,data)). Your mapping should be then as follows:

@RequestMapping(value="/updatestructure/",method = RequestMethod.PUT)
public @ResponseBody Structurenotification updateStructure(@RequestBody StructureNotificationDto ch) {
    return StructureNotif.update(ch);
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745538613a4632022.html

相关推荐

  • javascript - Request method 'PUT' not supported - Stack Overflow

    I'm working with springboot angularsjs and restful.my rest controller@RequestMapping(value="

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信