Path variable
A path variable is a named value embedded in a request URL path and made available to the handler processing that request.
Go in Practice, Second Edition
A path variable is a named value captured from a matched URL path and made available to the request handler.
- How it is used
- Routes requests containing URL-path identifiers to handlers that need those values.
- How deep it goes
- Works through route registration, value extraction, integer conversion, and response checks; does not develop advanced router internals.
- Examples
- Demonstrates `GET /comments/{id}` for comment lookup and `GET /goodbye/{name}` for a named greeting response.
- What you can do after
- Apply it via Go’s ServeMux and Request.PathValue to read a named path segment in an HTTP handler.
Read how Go in Practice, Second Edition explains path variable →
Spring in Action, Sixth Edition
A path variable is a value embedded in a URL path and bound to a controller method parameter.
- How it is used
- Retrieves one REST resource by binding a URL path value to a controller method parameter.
- How deep it goes
- Explains placeholders, parameter binding, repository lookup, Optional results, and explicit 404 handling.
- Examples
- Uses a taco endpoint that maps /api/tacos/{id} to a repository lookup by Long ID.
- What you can do after
- Apply it via Spring REST annotations to retrieve an identified resource and return an appropriate success or not-found response.
Read how Spring in Action, Sixth Edition explains path variable →
Related concepts
- @pathvariableuses · @PathVariable is a Spring MVC annotation that binds a controller method parameter to a variable embedded in the request path.
- uriuses · A URI (Uniform Resource Identifier) is a standardized character sequence that identifies an abstract or physical resource.
- routingused by · Routing is the selection of a path, destination, or processing component to direct an item, request, or flow toward an intended endpoint.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

