You can solve this in two ways:
First way: If you wish to keep using REST you have to you a ModelAndView
object to render a HTML page. An example is being posted by Happy Nguyen and I am posting it once more here:
@RequestMapping("/")
public ModelAndView index () {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("index");
return modelAndView;
}
Second Way: If it is not important weather you keep using REST or not, so you can just change the @RestController
to @Controller
and make sure that you have already added Thymeleaf template engine.