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

Welcome page support bypasses controllers mapped to / #21909

Closed
jumal opened this issue Jun 13, 2020 · 2 comments
Closed

Welcome page support bypasses controllers mapped to / #21909

jumal opened this issue Jun 13, 2020 · 2 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@jumal
Copy link

jumal commented Jun 13, 2020

The new welcome page support added in Spring Boot 3.2.1 bypasses controllers mapped to / when an "index" template exists.

This prevents the template's model to be populated.

Spring Boot version: 2.3.1

Sample application reproducing the problem: welcome-page-issue.zip

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 13, 2020
@bclozel bclozel self-assigned this Jun 13, 2020
@heanbian
Copy link

I have the same question.
Please give the solution.

@bclozel bclozel added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 15, 2020
@bclozel bclozel added this to the 2.3.2 milestone Jun 15, 2020
@bclozel
Copy link
Member

bclozel commented Jun 15, 2020

Sorry about that.

In #9785, we've implemented that feature using a RouterFunction bean that is registered if we detect an index.html static file or an index template file.

The problem comes from the fact that:

  • RouterFunction beans are ordered at Ordered.LOWEST_PRECEDENCE by default, and there's no way to order the welcome page one after the user-defined one (they would have to be ordered at a higher priority)
  • the RouterFunctionMapping defined by WebFlux is ordered before the annotation one, so it will take precedence no matter what

As a temporary workaround, you can rename your existing index template file to anything else; of course, you'll need to update your Controller or handler to target that new template file. This will deactivate the welcome page support.

As a fix, we'll create a different HandlerMapping component and order it after both the RouterFunction and the RequestMapping ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants