For a webflux project(using 2.0.0.M2) the welcome page in classpath:/static/index.html is not getting resolved for root uri / and returns a 404 status.

However it is served out if I access /index.html explicitly.

Comment From: mikaelhg

A workaround:

import org.springframework.core.io.Resource
import org.springframework.http.MediaType.*
import org.springframework.web.reactive.function.server.ServerResponse.ok
import org.springframework.web.reactive.function.server.router

@Configuration
class ApplicationRoutes {

    @Value("classpath:/static/index.html")
    private lateinit var indexHtml: Resource

    @Bean
    fun mainRouter() = router {
        GET("/") {
            ok().contentType(TEXT_HTML).syncBody(indexHtml)
        }
    }
}

Comment From: imedvedko

Hi!

Question on stackoverflow contains workaround: https://stackoverflow.com/questions/45147280/spring-webflux-how-to-forward-to-index-html-to-serve-static-content

Comment From: sivaprasadreddy

Why not have addViewControllers(ViewControllerRegistry registry) method in WebFluxConfigurer similar to WebMvcConfigurer?

Comment From: wilkinsona

@sivaprasadreddy WebFluxConfigurer is part of Spring Framework.

Comment From: bclozel

Waiting for SPR-17389.

Comment From: jan-peremsky

@bclozel The commit 525e03d3b5e33494e80e5efb8c26ed80547c1676 affects spring boot applications defining their own explicit welcome pages via explicit RouterFunction bean. This is because the WelcomePageConfiguration has no @ConditionalOnXXX annotation so it effectively overrides/supersedes any welcome page configuration provided in the application because it is processed prior to the RouterFunction defined in the app. And if the explicit welcome page is rendered from a template with an explicit model ServerResponse.ok().render("index", model) it is not rendered correctly.

@Order annotation has to be used on the explicit welcome page RouterFunction.

If this behavior is intentional, it should be at least documented. Otherwise it is a bug.

Comment From: bclozel

@jan-peremsky See #21909

Comment From: xJoeWoo

@bclozel The commit 525e03d affects spring boot applications defining their own explicit welcome pages via explicit RouterFunction bean. This is because the WelcomePageConfiguration has no @ConditionalOnXXX annotation so it effectively overrides/supersedes any welcome page configuration provided in the application because it is processed prior to the RouterFunction defined in the app. And if the explicit welcome page is rendered from a template with an explicit model ServerResponse.ok().render("index", model) it is not rendered correctly.

@Order annotation has to be used on the explicit welcome page RouterFunction.

If this behavior is intentional, it should be at least documented. Otherwise it is a bug.

Totally agreed!

RouterFunction bean method is marked @ConditionalOnMissingBean(RouterFunction::class) in my util library. It collects custom routers and transform them into Spring's RouterFunction. Now all projects that depends on util library got 404 due to no routers were registered! @Order(0) was useless, @ConditionalOnMissingBean had to be removed for now.

Will next update fix the pollution of RouterFunction?

Comment From: bclozel

@xJoeWoo See #21909

Comment From: xJoeWoo

@bclozel Thanks! Is there any clues about the release time of new version?

Comment From: bclozel

The scheduled release dates are available on GitHub. See https://github.com/spring-projects/spring-boot/milestone/173