Skip to content

Instantly share code, notes, and snippets.

@iamakimmer
Created March 23, 2013 20:21
Show Gist options
  • Save iamakimmer/5229207 to your computer and use it in GitHub Desktop.
Save iamakimmer/5229207 to your computer and use it in GitHub Desktop.
how to set up your spring config to respond to json/xml
<!-- Enable annotation scanning. -->
<context:component-scan base-package="com.matthewjkim.controllers" />
<!-- Map objects to XML. -->
<bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller" />
<bean id="xmlMessageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<constructor-arg ref="xstreamMarshaller" />
</bean>
<bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
<!-- Bind the return value of the Rest service to the ResponseBody. -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<util:list id="beanList">
<ref bean="xmlMessageConverter" />
<ref bean="jsonHttpMessageConverter" />
</util:list>
</property>
</bean>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment