samedi 21 mars 2015

ajax post request to Spring MVC Controller not working

I am facing the error - Failed to load resource: the server responded with a status of 415 (Unsupported Media Type)


ajax portion of my code is as follows



$.ajax({
url:'/authentication/editUser',
type:"POST",
contentType: "application/json",
data: JSON.stringify(requestObj), //Stringified Json Object
success: function(resposeJsonObject){
}});


and the controller's handler method:



@RequestMapping(value = "/editUser" , method = RequestMethod.POST, headers = {"Content-type=application/json"})
@ResponseBody
public EditUserResponse editUserpost(@RequestBody EditUserRequest editUserRequest){


System.out.println(editUserRequest);

return new EditUserResponse();
}


how to resolve the error ?


Aucun commentaire:

Enregistrer un commentaire