I have created a folder static inside the resources folder of my Spring Boot application. Inside the static folder I have an index.html file. Then I added this to my configuration:
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/");
}
Now I can access index.html at localhost:8080/index.html, but what I want to do is to access it at localhost:8080. I have tried this already:
@Override
protected void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("forward:/index.html");
}
But I get that "forward:/index.html"is not recognized by ServletDispatcher. Can someone help me with this? Thanks in advance.
EDIT
I solved the problem by deleting all my custom configuration, so the default configuration is available to my app. In my particular case, this works for me, but it wouldn't be bad to know how to achieve this with custom configurations. So this question is still open, everybody is welcome to give some input on the subject.