| Annotation | Lấy từ | Ví dụ |
|---|---|---|
@PathVariable | URI path segment | GET /users/42 |
@RequestParam | Query string | GET /users?page=2&size=10 |
@RequestBody | Request body (JSON) | POST /users |
@PathVariable— resource identifier (ID, slug) trong path, bắt buộc:@GetMapping("/users/{id}")+@PathVariable Long id.@RequestParam— filter/paging/sort từ query string, optional và có default:@RequestParam(defaultValue = "0") int page.@RequestBody— payload phức tạp khi create/update: Jackson deserialize JSON body → Java object, thường kèm@Validđể validate.
Kết hợp được trong cùng method: path cho ID, query cho option, body cho data.