I can not send a json
to a Spring MVC controller, I do not have any errors, but the controller does not print anything, I do not know what I'm failing.
Javascript Ajax:
var search = {
"pName" : "bhanu",
"lName" : "prasad"
}
var enviar = JSON.stringify(search);
$.ajax({
type: "POST",
contentType: 'application/json; charset=utf-8',
url: 'http://localhost:8080/HelloSpringMVC/j',
data: enviar, // Note it is important
success: function(result) {
// do what ever you want with data
}
});
Spring MVC:
@RequestMapping(value = "/j", method = RequestMethod.POST)
public void posted(@RequestBody Search search) {
System.out.println("Post");
System.out.println(search.toString());
}