I' not able to send a JSON object with JQuery Ajax to a Spring MVC controller. This is the definition of the method of my controller:
@Controller
@RequestMapping(value = "InboxViewTemplate")
public class InboxViewController {
@ResponseBody
@RequestMapping(value = "updateInboxView")
public String updateInboxView(HttpServletRequest request, InboxView inboxView) {
...
}
then I'm trying to invoke this request:
$.ajax({
dataType: 'json',
contentType: "application/json",
url: ctx + "/InboxViewTemplate/updateInboxView",
data: ({inboxView : {createUser:"dave"}}),
success: function(data) {
$("#updateInboxView").html(data);
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR + " : " + textStatus + " : " + errorThrown);
}
});
}
but the JSON object is not passed. Can someone help me? Thanks in advance.