ContentNegotiatingViewResolver Issue
Posted
by Jay
on Stack Overflow
See other posts from Stack Overflow
or by Jay
Published on 2010-05-19T07:04:12Z
Indexed on
2010/05/19
7:10 UTC
Read the original article
Hit count: 294
spring-mvc
How to map a url of this kind "/myapp/sample" to map to the default MarshallingView instead of a JSTLView.
@RequestMapping("/vets")
public ModelMap vetsHandler() {
Vets vets = new Vets();
vets.getVetList().addAll(this.clinic.getVets());
return new ModelMap(vets);
}
The above code works fine. When i tried to use http://.../vets.xml, I was able to download the xml.
But,
@RequestMapping("/myapp/vets")
public ModelMap vetsHandler() {
Vets vets = new Vets();
vets.getVetList().addAll(this.clinic.getVets());
return new ModelMap(vets);
}
doesn't resolve to the XML MarshalView, instead it resolves to JSTLView. Any thoughts?
below is the spring v 3 configuration from the petclinic example, that i'm using.
<bean id="vets" class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="contentType" value="application/vnd.springsource.samples.petclinic+xml"/>
<property name="marshaller" ref="marshaller"/>
</bean>
<bean id="test" class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="contentType" value="application/vnd.springsource.samples.petclinic+xml"/>
<property name="marshaller" ref="marshaller"/>
</bean>
<oxm:jaxb2-marshaller id="marshaller">
<oxm:class-to-be-bound name="org.springframework.samples.petclinic.Vets"/>
<oxm:class-to-be-bound name="org.springframework.samples.petclinic.Test1"/>
</oxm:jaxb2-marshaller>
© Stack Overflow or respective owner