I've got static
folder with following structure:
index.html
docs/index.html
Spring Boot correctly maps requests /
to index.html
. But it doesn't map /docs/
request to /docs/index.html
(/docs/index.html
request works correctly).
How to map folder/subfolder requests to appropriate index.html
files?
Spring boot show index.html by default.
but index.html should be in /resource/static or /public
example:
You can manually add a view controller mapping to make this work:
The first mapping causes Spring MVC to send a redirect to the client if
/docs
(without trailing slash) gets requested. This is necessary if you have relative links in/docs/index.html
. The second mapping forwards any request to/docs/
internally (without sending a redirect to the client) to theindex.html
in thedocs
subdirectory.It's not Spring Boot mapping to index.html it's the servlet engine (it's a welcome page). There's only one welcome page (per the spec), and directory browsing is not a feature of the containers.