ContentNegotiatingViewResolver Issue
- by Jay
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>