I got a simple spring boot application. I am trying load the html file through a rest controller. Below is my folder structure. I am unable to load test.html (just as helloworld code inside it)
@RequestMapping("/show1")
public ModelAndView showpage1() {
System.out.println("## show1");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("test");
return modelAndView;
}
My test.html content
<h1> hello World </h1>
Try doing this :
@RequestMapping("/show1")
public String showpage1() {
return "test";
}
where test.html is your page
Answer:
You just need to return the string with the name of the view.
@RequestMapping("/showpage")
public String showpage1() {
return "test";
}