Skip to content

Spring 4.1 with WebMvcConfigurationSupport enabled does not register a default view resolver [SPR-12267] #16872

@spring-projects-issues

Description

@spring-projects-issues

kyle leonhard opened SPR-12267 and commented

After upgrading to 4.1.0 I noticed that jsp views were no longer resolving. The app wasn't explicitly creating any view resolvers so I assumed some default resolvers had changed. I went a digging a bit and found the below.

The DispatcherServlet registers, if no viewResolvers have been registered, default view resolvers in initViewResolvers. This causes leads to an InternalResourceViewResolver being registered. Before upgrading to 4.1 this is the resolver that was resolving my app's views.

First, the app is using @EnableWebMvc. In 4.1 WebMvcConfigurationSupport added the mvcViewResolver method which registers a composite view resolver. In my case the viewResolverRegistry contains no viewResolvers so the composite resolver has nothing to delegate to. The registered composite view resolver causes the initViewResolvers method in DispatcherServlet to skip registration of the default view resolvers. My app ends up with no useful viewResolvers registered (just the composite with no delegates).

The issue is easy to work around (register a viewResolver), but it seems non-intuitive that enabling WebMvc support would cause this.

Let me know if there are any more details I can provide or if there are suggestions on how to better configure things.


Affects: 4.1 GA

Issue Links:

Referenced from: commits 803fc20, 49cf30e

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions