In this recipe, you will learn how to define a controller method to be executed for a given route.
Here are the steps for creating a controller method for a given route:
Create a controller class in your controller package (for example,
com.springcookbook.controller
). This is a normal Java class annotated with@Controller
:@Controller public class UserController { ... }
Add a controller method. This is a standard Java method annotated with
@RequestMapping
, which takes the route as a parameter:@RequestMapping("/user/list") public void userList() { ... }