// GET /api/users/42
@GetMapping("/{id}")
public User getUser(@PathVariable Long id) { ... }
// GET /api/users?page=2&size=20
@GetMapping
public List<User> list(@RequestParam int page, @RequestParam(defaultValue = "10") int size) { ... }- @PathVariable — part of the URL path itself, usually an identifier
- @RequestParam — optional query string key=value pairs, supports defaultValue