Closed
Description
Paul Chapman opened SPR-13559 and commented
In the following, does the ContentNegotiatingViewResolver
created by <mvc:view-resolvers>
automatically get set with the mvcContentNegotiationManager
? My tests are telling me not.
<mvc:annotation-driven
content-negotiation-manager="mvcContentNegotiationManager" />
<!-- View resolver chain -->
<mvc:view-resolvers>
<mvc:content-negotiation use-not-acceptable="true" />
<mvc:bean-name />
<mvc:tiles />
<bean class="rewardsonline.accounts.JsonViewResolver" />
</mvc:view-resolvers>
<bean id="mvcContentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="ignoreAcceptHeader" value="true" />
<property name="defaultContentType" value="text/html" />
</bean>
Running this as a servlet app does work, but my MockMvc test fails trying to generate JSON.
If I explicitly get the ContentNegotiatingViewResolver
when the test starts and manually set the ContentNegotiationManager
to mvcContentNegotiationManager
, it works.
I would expect the CNVR created using <mvc:view-resolvers/>
to be initialised with the same ContentNegotiationManager
that was specified to <mvc:annotation-driven>
.
Affects: 4.1.7, 4.2.1
Referenced from: commits 0f1897d, c599514, 563a120, f84a0c9
Backported to: 4.1.9