Annotation Interface PathVariable
Annotation that binds a method variable to a path parameter.
Example
@Controller("/api")
public class MyController {
// Incoming request looks like "/api/user/123"
@GetMapping("/user/{userId}")
public UserData getUserData(@PathVariable("userId") String theUserId) {
return UserDao.getUserData(theUserId);
}
}
As you can see, the @PathVariable
's parameter name does not need to
match the actual method parameter's name.- Since:
- 1.0
- Version:
- 2022-08-30
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
String valueThe name of the path variable to map to.- Default:
- ""
-