I\'m starting an embedded tomcat via spring-boot and want to serve a static index.html page as part of a running application.
But the follo
My fault: I had an additional class with @EnableWebMvc annotation. This somehow messed up the spring-boot autoconfiguration. I removed it and now it works returning index.html.
For me this worked, i am sure there is a better way ( like without .html ).
@RequestMapping("/")
public String index() {
return "index.html";
}
You can use ModelAndView in order to serve static HTML content in spring boot.
@RequestMapping("/")
public ModelAndView home()
{
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("index");
return modelAndView;
}
application.properties:-
spring.mvc.view.suffix = .html
HTML File : - src/main/resources/static/index.html
Thats because of @RestController annotation, just removing this annotation works for me.