Card 01/ 06
All 6 cards
ConceptDifficulty: Intermediate1 min
One Annotation per HTTP Verb
A REST controller method needs Spring to know two things about the request it should answer: which HTTP verb, and which path. @GetMapping("/rides/{id}") says both in one line.
| Annotation | Verb |
|---|---|
@GetMapping | GET — read, no side effect |
@PostMapping | POST — create |
@PutMapping | PUT — replace |
@DeleteMapping | DELETE — remove |
All four are specialisations of the more general @RequestMapping, which takes the verb as an argument instead of baking it into the annotation's name — the specific ones exist so the verb is visible at a glance, without reading into the parentheses.