Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Sep 27, 2014 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 27, 2014

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

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Sep 29, 2014

Rossen Stoyanchev commented

Actually this is what we had initially before an issue surfaced where another ViewResolver with default order (lowest precedence) may be "shadowed", see #16629. Seems like we need to refine the approach and check if other ViewResolver beans exist. That was we can preserve the DispatcherServlet default behavior when no ViewResolver declarations are made.

@spring-projects-issues
Copy link
Collaborator Author

kyle leonhard commented

Thanks. Keep up the good work!

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

No worries, thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants