From 0d902c13231f9f39a6e08c9764c518ae20c551bb Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 11 Sep 2023 15:04:43 +0200 Subject: [PATCH] Document Welcome Page support ordering This commit documents the relative ordering of `HandlerMapping` support in Spring MVC and WebFlux applications. As of Spring Framework 6.1.0, the Welcome Page support acts as a fallback in case no index route has been defined by the application as a `RouterFunction` or within an annotated `@Controller`. Closes gh-34846 --- .../src/docs/asciidoc/web/reactive.adoc | 15 +++++++++++++++ .../src/docs/asciidoc/web/servlet.adoc | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc index 7b1c23005c..fbae93af9c 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc @@ -120,6 +120,21 @@ It first looks for an `index.html` file in the configured static content locatio If one is not found, it then looks for an `index` template. If either is found, it is automatically used as the welcome page of the application. +This only acts as a fallback for actual index routes defined by the application. +The ordering is defined by the order of `HandlerMapping` beans which is by default the following: + +[cols="1,1"] +|=== +|`RouterFunctionMapping` +|Endpoints declared with `RouterFunction` beans + +|`RequestMappingHandlerMapping` +|Endpoints declared in `@Controller` beans + +|`RouterFunctionMapping` for the Welcome Page +|The welcome page support +|=== + [[web.reactive.webflux.template-engines]] diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc index c965ce1821..86ed5fbc32 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc @@ -196,6 +196,20 @@ It first looks for an `index.html` file in the configured static content locatio If one is not found, it then looks for an `index` template. If either is found, it is automatically used as the welcome page of the application. +This only acts as a fallback for actual index routes defined by the application. +The ordering is defined by the order of `HandlerMapping` beans which is by default the following: + +[cols="1,1"] +|=== +|`RouterFunctionMapping` +|Endpoints declared with `RouterFunction` beans + +|`RequestMappingHandlerMapping` +|Endpoints declared in `@Controller` beans + +|`WelcomePageHandlerMapping` +|The welcome page support +|=== [[web.servlet.spring-mvc.favicon]]