I'm using the Spring Roo and generated an application. I want to have on it RESTful services. I don't know if i need to implement or if spring already do this for me.
I followed the links:
http://static.springsource.org/sprin...l/ch18s02.html
If i go to http://localhost:8080/geoLocationApp/address.xml the xml responsed is very good, with only "address" objects inside the list. That's ok.
But if I want to get only a object, I do the url:
http://localhost:8080/geoLocationApp/address/1.xml
The result is very big, with a lot of objects I don't want. I don't know if I need to customize my own marshaller or if the CastorMarshaller of spring 3 would do that.
Here is the example of the result of the URL http://localhost:8080/geoLocationApp/address.xml;
Here is the example of the url http://localhost:8080/geoLocationApp/address/2.xml. It's Very poluted:Code:<array-list> − <Address xsi:type="Address"> <ident>1</ident> <descricao>Evil address.</descricao> <version>0</version> </Address> − <Address xsi:type="Address"> <ident>2</ident> <descricao>Rua Barroso.</descricao> <version>0</version> </Address> </array-list>
And My contentNegotiationResolver:Code:<bean-property-binding-result field-error-count="0" global-error-count="0" error-count="0"> − <property-accessor auto-grow-nested-paths="true" extract-old-value-for-editor="true" xsi:type="java:org.springframework.beans.BeanWrapperImpl"> − <root-instance xsi:type="Address"> <ident>2</ident> </root-instance> <nested-path/> − <wrapped-instance xsi:type="Address"> <ident>2</ident> </wrapped-instance> − <property-descriptors bound="false" constrained="false" expert="false" hidden="false" preferred="false" xsi:type="java:org.springframework.beans.GenericTypeAwarePropertyDescriptor"> <display-name>id</display-name> <name>id</name> <short-description>id</short-description> </property-descriptors> − <property-descriptors bound="false" constrained="false" expert="false" hidden="false" preferred="false" xsi:type="java:org.springframework.beans.GenericTypeAwarePropertyDescriptor"> <display-name>class</display-name> <name>class</name> <short-description>class</short-description> </property-descriptors> − <property-descriptors bound="false" constrained="false" expert="false" hidden="false" preferred="false" xsi:type="java:org.springframework.beans.GenericTypeAwarePropertyDescriptor"> <display-name>descricao</display-name> <name>descricao</name> <short-description>descricao</short-description> </property-descriptors> − <property-descriptors bound="false" constrained="false" expert="false" hidden="false" preferred="false" xsi:type="java:org.springframework.beans.GenericTypeAwarePropertyDescriptor"> <display-name>version</display-name> <name>version</name> <short-description>version</short-description> </property-descriptors> <conversion-service xsi:type="java:org.springframework.format.support.FormattingConversionService"/> </property-accessor> − <property-editor-registry auto-grow-nested-paths="true" extract-old-value-for-editor="true" xsi:type="java:org.springframework.beans.BeanWrapperImpl"> − <root-instance xsi:type="Address"> <ident>2</ident> </root-instance> <nested-path/> − <wrapped-instance xsi:type="Address"> <ident>2</ident> </wrapped-instance> − <property-descriptors bound="false" constrained="false" expert="false" hidden="false" preferred="false" xsi:type="java:org.springframework.beans.GenericTypeAwarePropertyDescriptor"> <display-name>id</display-name> <name>id</name> <short-description>id</short-description> </property-descriptors> − <property-descriptors bound="false" constrained="false" expert="false" hidden="false" preferred="false" xsi:type="java:org.springframework.beans.GenericTypeAwarePropertyDescriptor"> <display-name>class</display-name> <name>class</name> <short-description>class</short-description> </property-descriptors> − <property-descriptors bound="false" constrained="false" expert="false" hidden="false" preferred="false" xsi:type="java:org.springframework.beans.GenericTypeAwarePropertyDescriptor"> <display-name>descricao</display-name> <name>descricao</name> <short-description>descricao</short-description> </property-descriptors> − <property-descriptors bound="false" constrained="false" expert="false" hidden="false" preferred="false" xsi:type="java:org.springframework.beans.GenericTypeAwarePropertyDescriptor"> <display-name>version</display-name> <name>version</name> <short-description>version</short-description> </property-descriptors> <conversion-service xsi:type="java:org.springframework.format.support.FormattingConversionService"/> </property-editor-registry> − <model xsi:type="java:org.exolab.castor.mapping.MapItem"> − <key xsi:type="java:java.lang.String"> org.springframework.validation.BindingResult.address </key> </model> − <model xsi:type="java:org.exolab.castor.mapping.MapItem"> <key xsi:type="java:java.lang.String">address</key> − <value xsi:type="Address"> <ident>2</ident> </value> </model> <message-codes-resolver xsi:type="java:org.springframework.validation.DefaultMessageCodesResolver"/> − <target xsi:type="Address"> <ident>2</ident> </target> <nested-path/> <object-name>address</object-name> </bean-property-binding-result>
Code:<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <entry key="json" value="application/json" /> <entry key="xml" value="application/xml" /> </map> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> <bean class="org.springframework.web.servlet.view.xml.MarshallingView"> <constructor-arg> <bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"> <property name="mappingLocation" value="classpath:mapping.xml" /> </bean> </constructor-arg> </bean> </list> </property> <property name="ignoreAcceptHeader" value="true" /> </bean>


Reply With Quote
.
