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

Comment From: heanbian

I have the same question. Please give the solution.

Comment From: bclozel

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.