I am using ContentNegotiatingViewResolver in my spring config to setup json, xml, xls, and html (via jstl) outputs from a RESTful service using MVC.
All of these outputs are functioning, but the XML output is very verbose.
In the MVC, I have this:
and when I go to someserver/someapp/api/person/1.json its perfect, 1.html works great going to the view I return in the MAV.Code:@Secured({"ROLE_USER"}) @RequestMapping(value = "/api/person/{personid}", method = RequestMethod.GET) public ModelAndView GetPerson(@PathVariable("personid") long personid) { // some code here return mav; }
However, when I select XML, I get > 100kb of what appears to be complete state information, with pages/pages/pages of serialization stuff. Here is a snippet:
then at the very bottom, I see this:Code:<org.springframework.validation.BeanPropertyBindingResult> <nestedPath/> <nestedPathStack serialization="custom"> <unserializable-parents/> <vector> <default> <capacityIncrement>0</capacityIncrement> <elementCount>0</elementCount> thousands of lines omitted for brevity
which is a reasonable representation of what I actually want (notice I am using hibernate).Code:<target class="PersonOutput"> <code>100</code> <message>Success</message> <person> <Person> <personid>6335</personid> <Events class="org.hibernate.collection.PersistentBag"> <initialized>true</initialized> dozen of lines omitted for brevity
I am using this View in my spring config:
What I really want is a very simplistic xml representation without all of the serialization or rpc type output which is suitable for another application to use as a data file (not to re-instate the object somewhere else).Code:<bean class="org.springframework.web.servlet.view.xml.MarshallingView"> <constructor-arg> <bean class="org.springframework.oxm.xstream.XStreamMarshaller" /> </constructor-arg> </bean>
This is how the json output works, what can I do to get the XML to work as well?
Thanks in advance,
Tim


Reply With Quote
