May 2015
Intermediate to advanced
234 pages
4h 18m
English
In this recipe, we will define in one place a route prefix shared by all the routes of a controller. We will start the routes of the UserController controller with /user.
Here are the steps to set a route prefix:
@RequestMapping with the common route prefix to the controller class:@Controller
@RequestMapping("/user")
public class UserController {
...
}@RequestMapping with the remainder of the route to the controller methods:@RequestMapping("/list")
public void userList() {
...
}
@RequestMapping("/add")
public void addUser() {
...
}A request for the /user/add route will execute the addUser()method. A request for the /user/list route will execute the userList() ...
Read now
Unlock full access