I know using mvc:annotation-driven will give me that for free. But I’d like to have more control of it.
my config is like the following:
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="order" value="1" />
<property name="mediaTypes">
<map>
<entry key="json" value="application/json" />
<entry key="xml" value="text/xml"/>
</map>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
<property name="prefixJson" value="false" />
<property name="objectMapper" ref="jacksonObjectMapper" />
</bean>
<bean class="org.springframework.web.servlet.view.xml.MarshallingView" >
<property name="marshaller">
<bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.appservices.dtos"/>
</bean>
</property>
</bean>
</list>
</property>
</bean>
Spring does not like the contextPath property, how to tell it to scan some package to find all jaxb beans? Thanks.
have you tried with classesToBeBound property? In any case your problem has nothing to do with spring mvc or contentnegotiatingViewResolver, is with Jaxb2Marshaller