liveBook · Manning

@pathvariable

@PathVariable is a Spring MVC annotation that binds a controller method parameter to a variable in the request path.

How 2 Manning books explain it

Spring Microservices in Action

A Spring annotation that binds a method parameter to a value in a URI template.

How it is used
Binds URI template values to controller method parameters in a microservice endpoint.
How deep it goes
Explains the binding with a worked controller example without discussing implementation internals.
Examples
Uses organization and license identifiers in a licensing service GET handler.
What you can do after
Apply it via Spring to bind path identifiers in a controller method.

Read how Spring Microservices in Action explains @pathvariable →

Spring in Action, Sixth Edition

@PathVariable is a Spring MVC annotation that binds a controller method parameter to a variable in the request path.

How it is used
Binds URL path values to controller parameters for resource-specific REST endpoints.
How deep it goes
Explains placeholder mapping and repository use, then addresses missing resources with ResponseEntity and HTTP 404.
Examples
Uses GET /api/tacos/{id} to retrieve individual Taco objects by numeric ID.
What you can do after
Build it from scratch by mapping a path identifier to repository-backed controller logic.

Read how Spring in Action, Sixth Edition explains @pathvariable →

Related concepts

Questions about @pathvariable

What is @pathvariable?

@PathVariable is a Spring MVC annotation that binds a controller method parameter to a variable in the request path.

Which Manning books explain @pathvariable?

Spring Microservices in Action and Spring in Action, Sixth Edition.

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.