I am trying to update some data using $http.post method from angularjs to Spring MVC controller. But I get error as "HTTP Status 405 - Request method 'GET' not supported". My code snippets are as below :
//AngularJS Service
updateData : function(data) {
return $http.post('updateData', data).then(
function(response){
// success callback
return response;
},
function(response){
// failure callback
return response;
}
);
}
where data is as below :
data = [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' },{ id: 3, name: 'baz' }];
//Spring MVC controller code
@RequestMapping(value="/updateData", method = RequestMethod.POST)
public @ResponseBody String updateData(@RequestBody Company company) throws Exception {
// I have created POJO for company with id and name getter-setter
// logic to update the data in db
//System.out.println(company.getName());
return "success";
}
Any error in my code?