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
@PathVariable
@PathVariable it is the annotation, that is used in the URI for the incoming request.
http://localhost:8080/restcalls/101?id=10&name=xyz
@RequestParam
@RequestParam annotation used for accessing the query parameter values from the request.
public String getRestCalls(
@RequestParam(value="id", required=true) int id,
@RequestParam(value="name", required=true) String name){...}
Note
whatever we are requesting with rest call i.e, @PathVariable
whatever we are accessing for writing queries i.e, @RequestParam