request mapping
The annotations, such as @GetMapping("/orders/{id}"), that connect an HTTP method and path to a controller method.
In more detail
The path and verb are public API: clients, caches and documentation depend on them, so changing either is a contract change. Use nouns for resource paths and let the HTTP method express the operation.
Example
@GetMapping("/orders/{id}")Related terms
- controller (Spring) — A Spring class, usually marked @RestController, whose methods handle HTTP requests for particular paths and return response bodies.
- HTTP method — The verb at the start of a web request that says what the client wants, such as GET to read or POST to create.
- route — The combination of HTTP method and URL path that a server maps to one handler, such as GET /orders/{id}.
- path variable — A placeholder segment in a route, such as {id} in /orders/{id}, whose value is taken from the request URL.
Taught in
- Controllers And Routing — Modern Java: Virtual Threads & High-Throughput Services
- Reading The Request — Modern Java: Virtual Threads & High-Throughput Services
- Implementing An OpenAPI Contract — Modern Java: Virtual Threads & High-Throughput Services