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
QueryParam:
To assign URI parameter values to method arguments. In Spring, it is @RequestParam
.
Eg.,
http://localhost:8080/books?isbn=1234
@GetMapping("/books/")
public Book getBookDetails(@RequestParam("isbn") String isbn) {
PathParam:
To assign URI placeholder values to method arguments. In Spring, it is @PathVariable
.
Eg.,
http://localhost:8080/books/1234
@GetMapping("/books/{isbn}")
public Book getBook(@PathVariable("isbn") String isbn) {