-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug
Milestone
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
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug