I\'ve got static folder with following structure:
index.html
docs/index.html
Spring Boot correctly maps reque
You can manually add a view controller mapping to make this work:
@Configuration
public class CustomWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/docs").setViewName("redirect:/docs/");
registry.addViewController("/docs/").setViewName("forward:/docs/index.html");
super.addViewControllers(registry);
}
}
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 the index.html in the docs subdirectory.