Skip to main content

@PathVariable

Learn @PathVariable (Request Handling, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Fresher Notes @PathVariable binds a URI template variable to a method argument: @GetMapping("/users/{id}") with @PathVariable Long id . Name matching : the argument name must equal the placeholder, or be given explicitly, as in @PathVariable("id") Long userId . Required : by default the variable is required; a missing one means the mapping did not match.

More lessons in Request Handling