This is a request to improve the documentation about serving static content documented in section 4.7.2 of the spring boot reference guide (v2.4.2).

The setting to publish static content does not seem to work either for Spring Web and Web Flux generated applications. The steps to reproduce are detailed in this stackoverflow post under Steps to reproduce.

The section Alternative 2: this works in the same stackoverflow post shows that static content serving works using a different property for a Spring Web app.

Comment From: mbhave

@adelinor The behavior described in the documentation is the expected behavior. It's not clear what you would like improved in the docs.

If you're seeing that it's not behaving as described in the docs, this would be a bug in the implementation. However, I tried to reproduce the issue with the steps listed in the StackOverflow post but I was not able to. Setting both SPRING_RESOURCES_STATICLOCATIONS (deprecated in 2.4.0) and SPRING_WEB_RESOURCES_STATICLOCATIONS worked for me for a spring-web and webflux application.

Can you provide a minimal sample that we can run to reproduce this issue?

Comment From: adelinor

Dear @mbhave ,

I repeated the steps listed in the StackOverflow post and found the problem :)

Generated project with Spring Reactive Web and Spring boot version 2.4.3: demo-webflux.zip

This project was unzipped to C:\Temp\issue-25397.

Static content placed under C:\Temp\issue-25397\static:

index.html.txt to be renamed to index.html

Run commands in GIT bash window:

export SERVER_PORT=8084
export SPRING_WEB_RESOURCES_STATICLOCATIONS=file:/c/Temp/issue-25397/static/

cd /c/Temp/issue-25397/demo-webflux
mvn spring-boot:run

Opening http://localhost:8084/index.html shows: Whitelabel Error Page (...) There was an unexpected error (type=Not Found, status=404).

Repeating similar steps but this time using a Windows command shell:

set SERVER_PORT=8084
set SPRING_WEB_RESOURCES_STATICLOCATIONS=file:C:\\Temp\\issue-25397\\static\\
mvn spring-boot:run

Opening http://localhost:8084/index.html (or simply http://localhost:8084) shows Hello World!

So it works as expected. Also going back to GIT BASH window, setting the location with

export SPRING_WEB_RESOURCES_STATICLOCATIONS=file:/Temp/issue-25397/static/

resolves the problem and works too. This issue can therefore be closed.