I am building a RESTful website with Spring 3.0. I use ContentNegotiatingViewResolver as well as HTTP Message Convertors (e.g. MappingJacksonHttpMessageConverter for JSON, MarshallingHttpMessageConverter for XML, etc.). I can get XML content successfully if I use the suffix .xml in the last URL and the same in the case of JSON with the suffix .json in the URL.
Getting the XML / JSON content from the controller does not pose any problems for me. But, how can I POST XML / JSON with the request body in the same controller method?
For instance,
@RequestMapping(method=RequestMethod.POST, value="/addEmployee") public ModelAndView addEmployee(@RequestBody Employee e) { employeeDao.add(e); return new ModelAndView(XML_VIEW_NAME, "object", e); }
source share