To my knowledge both serves the same purpose. Except the fact that @PathVariable is from Spring MVC and @PathParam is from JAX-RS. Any insights on
@PathParam: it is used to inject the value of named URI path parameters that were defined in @Path expression.
Ex:
@GET
@Path("/{make}/{model}/{year}")
@Produces("image/jpeg")
public Jpeg getPicture(@PathParam("make") String make, @PathParam("model") PathSegment car, @PathParam("year") String year) {
String carColor = car.getMatrixParameters().getFirst("color");
}
@Pathvariable: This annotation is used to handle template variables in the request URI mapping ,and used them as method parameters.
Ex:
@GetMapping("/{id}")
public ResponseEntity getByIdPatient(@PathVariable Integer id) {
Patient obj = service.getById(id);
return new ResponseEntity(obj,HttpStatus.OK);
}