@Controller marks a class as a Spring MVC controller. As a stereotype annotation like @Component or @Service, it lets Spring register the class as a managed bean. Its methods can handle specific HTTP requests. section 7.3
Listing 7.5 The definition of the controller class
@Controller #A
public class MainController {
@RequestMapping("/home") #B
public String home() {
return "home.html"; #C
}
}A minimal controller maps /home to a method that returns home.html. section 7.3
For a regular controller, a method’s return value can name a view. To return a REST response body directly, use @ResponseBody or @RestController; otherwise, Spring treats the return value as a view name. section 10.6
