First of all, your controller does not know where to look for InboxView. Is this a query parameter? Path param? Request a body?
Secondly, you probably want to change your json request type to POST or PUT, as you are updating the data, not just retrieving it.
So something like this:
@Controller @RequestMapping(value = "InboxViewTemplate") public class InboxViewController { @ResponseBody @RequestMapping(value = "updateInboxView", method = RequestMethod.POST) public String updateInboxView(HttpServletRequest request, @RequestBody InboxView inboxView) { ... }
and
$.ajax({ dataType: 'json', contentType: "application/json", url: ctx + "/InboxViewTemplate/updateInboxView", type: 'POST', data: JSON.stringify({inboxView : {createUser:"dave"}}), //if no JSON is available use the one from https://github.com/douglascrockford/JSON-js success: function(data) { $("#updateInboxView").html(data); }, error: function (jqXHR, textStatus, errorThrown) { alert(jqXHR + " : " + textStatus + " : " + errorThrown); } }); }
must work.
I assume that you have configured json message converter correctly.
change This means that you have:
<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="jacksonMessageConverter"/> </list> </property> </bean>
or something equivalent for other message converters in your spring xml configuration.
source share