The first controller works correctly,

@Controller @ComponentScan @EnableAutoConfiguration public class MainController { @RequestMapping("/profile") private String g(){ return "Profile.html"; } } 

Second:

 @Controller @RequestMapping(value = "/gallery") public class GContoller { @RequestMapping(value = "/month") String ffff() { return "monthGallery.html"; } @RequestMapping("/test") @ResponseBody String test() { return "Test"; } } 

The localhost:8080/gallery/test page opens and displays test, but localhost:8080/gallery/month displays error 404. Obviously, the second controller cannot find the file monthGallery.html, but how can I tell it to it? All html files are in /webapp .

Project structure

/java /ru.example.xxx /webapp

    1 answer 1

    Just add spring.view.prefix=/ to application.properties