Add ContentNegotiationManagerFactoryBean
The new FactoryBean facilitates the creation of a ContentNegotiationManager in XML configuration. Issue: SPR-8420
This commit is contained in:
@@ -4503,25 +4503,20 @@ public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
}
|
||||
}</programlisting>
|
||||
|
||||
<para>In XML you'll need to use the <code>content-negotiation-manager</code> property:</para>
|
||||
<para>In XML you'll need to use the <code>content-negotiation-manager</code>
|
||||
property of <code>annotation-driven</code>:</para>
|
||||
|
||||
<programlisting language="xml"><mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
|
||||
|
||||
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManager">
|
||||
<constructor-arg>
|
||||
<list>
|
||||
<ref bean="pathExtensionStrategy" />
|
||||
<bean id="headerStrategy" class="org.springframework.web.accept.HeaderContentNegotiationStrategy"/>
|
||||
</list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="pathExtensionStrategy" class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy">
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<entry key="xml" value="application/rss+xml" />
|
||||
</map>
|
||||
</constructor-arg>
|
||||
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||||
<property name="favorPathExtension" value="false" />
|
||||
<property name="favorParameter" value="true" />
|
||||
<property name="mediaTypes" >
|
||||
<value>
|
||||
json=application/json
|
||||
xml=application/xml
|
||||
</value>
|
||||
</property>
|
||||
</bean></programlisting>
|
||||
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user