As we know, nginx or apache hosting servers, when visitors go to a URL that requests a directory, such as http://example.com/products, the web server looks for a file in the products directory named index.html. If index.html exists, its contents would be displayed.
How can I configure spring boot to get the same effect?
Please note that I don't mean to set a default welcome page. I'd like to display index.html under every specific directory.
What I've done is as following:
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/home").setViewName("/home/index.html");
registry.addViewController("/products").setViewName("/products/index.html");
registry.addViewController("/home/profile").setViewName("/home/profile/index.html");
}
This can help me get what I want, but seems very stupid if I have lots of such folders. So I wonder if it can be realized automatically like nginx or apache servers. Thanks so much for any suggestion.