path variable
A placeholder segment in a route, such as {id} in /orders/{id}, whose value is taken from the request URL.
In more detail
In Spring, @PathVariable binds that segment to a method parameter and converts it to the parameter's type. A path variable should identify a resource and have one clear meaning and validation rule.
Example
String one(@PathVariable String id)Related terms
- request mapping — The annotations, such as @GetMapping("/orders/{id}"), that connect an HTTP method and path to a controller method.
- query parameter — A name and value added after the question mark in a URL, such as ?verbose=true, that refines a request.
- request binding — A framework converting parts of an HTTP request, such as path variables, query parameters, headers and the body, into typed method arguments.
Taught in
- Reading The Request — Modern Java: Virtual Threads & High-Throughput Services
- Implementing An OpenAPI Contract — Modern Java: Virtual Threads & High-Throughput Services