 Usually , stay Spring MVC in , We write a controller class to handle requests from clients . And then , The controller calls the service class to handle business-related tasks , Then redirect the client to the logical view name , The name is given by Spring Scheduling program for Servlet analysis , To present a result or output . This completes the typical request - The round trip of the response cycle . Today, I've sorted out and compiled Spring MVC Controller 14 A trick , You are get Have you arrived ?(≧▽≦)/ ### **1、 Use @Controller Tectonic type ** This is the easiest way to build a controller class that can handle one or more requests . Only by annotating a class with a stereotype @Controller , for example : ``` import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HomeController { @RequestMapping("/") public String visitHome() { return "home"; } } ``` As you can see ,visitHome() Method by redirecting to home View to handle the path from the application context (/) Request for . Be careful :@Controller Prototypes can only be Spring When annotation driven is enabled in the configuration file of