So I got json working where someone can post an object in json form, and my controller method maps that to the actual java object. My spring config xml looks like:
<bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<util:list id="beanList">
<ref bean="jsonMessageConverter"/>
</util:list>
</property>
</bean>
And a test controller method that works is like:
@ResponseBody
@RequestMapping(value = "/create", method = RequestMethod.POST)
public String create(@RequestBody User user, HttpServletRequest request, HttpServletResponse response) {
return user.getName();
}
Now if I want the exact same method to work with xml also, is this possible? Which message converter do I use?
BTW, if I want to keep certain properties of private, how can I do that so it works for both json and xml?
e.g. say I have a password property, I don't want anyone being able to post this information.