Card 06/ 06
Recap: Mapping Requests
Verbs and paths, the three places request data lives, and the response that matches the outcome.
Mapping requests comes down to the four ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
| Each mapping annotation names a verb and a path | Request Mapping Annotations: One per HTTP Verb |
@PathVariable, @RequestParam and @RequestBody read the path, the query string and the body | Request Mapping Example: Reading the Path, the Query String and the Body |
Choose the ResponseEntity method by the outcome: created() also sets Location | ResponseEntity Example: Choosing the Response That Matches the Outcome |
@RestController returns a body; @Controller returns a view name | @RestController vs @Controller: When a Returned String Becomes a 404 |
Read together, a controller's annotations and return types are the API's contract: what each request looks like and what each outcome sends back.
← → move through sections and cards