What is the difference between @RequestParam and @PathVariable while handling special characters?
+ was accepted by @Re
Both the annotations behave exactly in same manner.
Only 2 special characters '!' and '@' are accepted by the annotations @PathVariable and @RequestParam.
To check and confirm the behavior I have created a spring boot application that contains only 1 controller.
@RestController
public class Controller
{
@GetMapping("/pvar/{pdata}")
public @ResponseBody String testPathVariable(@PathVariable(name="pdata") String pathdata)
{
return pathdata;
}
@GetMapping("/rpvar")
public @ResponseBody String testRequestParam(@RequestParam("param") String paramdata)
{
return paramdata;
}
}
Hitting following Requests I got the same response:
!@ was received as response in both the requests