spring-mvc

What is the difference b/w @RequestParam and @QueryParam Anotation


What is main difference between @RequestParam and @QueryParam in Spring MVC controller?


Solution

  • Apart from these mentioned differences in framework, one major difference is @RequestParam will always expect a value to bind. Hence, if value is not passed, it will give error. This is not the case in @QueryParam

    To explicitly give the option, use required = false while using @RequestParam