Difference between QRequestParam and @PathVariable?

+1 vote
40 views
asked Jun 12 by admin (8,115 points)

Hi

  What is the Difference between @RequestParam and @PathVariable?

1 Answer

0 votes
answered Jun 12 by codeg (2,600 points)

Hi 

    Both annotations @RequestParam and @PathVariable in Spring MVC are used for fetching the values of request parameters. 

    These annotations have similar purpose but some differences in use. 

    The key difference between @RequestParam and @PathVariable is that @RequestParam used for accessing the values of the query parameters where as @PathVariable used for accessing the values from the URI template.

commented Jun 12 by codeg (2,600 points)
http://localhost:8080/tutorials/bookmark/100?site=dineshonjava

site is  @RequestParam
100 is @PathVariable
...