Open Global-Manu-Man opened 3 years ago
To my understanding and better clean code, I think doing it this way will give a clean code
@RestController
public class MyRestController {
@RequestMapping("/")
public ModelAndView welcome() {
ModelAndView model = new ModelAndView();
model.setViewName("login"); //removing .html extension
return model;
}
}
The problem I had was How to return a html page from a restful controller in spring boot?
Must put the html files in resources/templates/ or resources / public.
Replace the @RestController with @Controller.
Add dependency on thymeleaf.
Remove if you are using any view resolvers.
Your controller method should return file name of view without extension like return "index.html, user.html, admin.html".
Add view name is: 'login.html' (full file name).
and