Skip to content

When using Java-based configuration, nested ViewResolvers in ContentNegotiatingViewResolver may require bean initialization [SPR-8350] #12997

@spring-projects-issues

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-8350 and commented

The ContentNegotiatingViewResolver supports a property with nested ViewResolvers. When using Java-based configuration this property is likely to be populated with ViewResolvers created in the same method and not by an ApplicationContext. Some ViewResolvers however implement ApplicationContextAware and depend on access to an ApplicationContext (e.g. UrlBasedViewResolver and sub-classes).

Of course it is possible to create the nested ViewResolvers from separate @Bean methods but that's not ideal and seems to defeat the purpose of having nested ViewResolvers in the first place. Instead the ContentNegotiatingViewResolver can check if the provided ViewResolvers are registered in the container and if not initialize them through the BeanFactory.


Affects: 3.0.5

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions