rest web services
Last updated
Was this helpful?
Last updated
Was this helpful?
Even though both @RequestParam and @ParthVariable is used to extract values from the HTTP request, there is a subtle difference between them.
The @RequestParam is used to extract query parameters while @PathVariable is used to extract data right from the URI.
@RequestParam is more useful on a traditional web application where data is mostly passed in the query abatements while @PathVariable is more suitable for RESTful web services where URL contains values e.g. , here data, which is ISBN number is part of URI.
@RequestParam annotation can specify default values if a query parameter is not present or empty by using a defaultValue attribute, provided the required attribute is false.
Spring MVC allows you to use multiple @PathVariable annotations in the same method, provided, no more than one argument has the same pattern.