3

How to send % using @RequestParam in Spring ?

I'm calling the API by this URL : http://localhost:8080/springmvc/test?param1=%

But I'm not able to get the % in the API. When I'm debugging, I'm getting param1 = null but I want to get the real character %. How to get that ?

This is my API :

public List<Test> testParam(
            @PathVariable("test") string test,
            @RequestParam(value = "param1", required = false) string myParaml) {
  ...
}
Anish B.
  • 9,111
  • 3
  • 21
  • 41
sevenfold
  • 101
  • 8

2 Answers2

3

Use URL encoding for special symbols as parameters

%   =  %25

Reference

You need to decode if want to read in Java Ref 2

VedantK
  • 9,728
  • 7
  • 66
  • 71
2

You have to send special characters in UTF-8 encoded standard in the URL.

Try to send % as %25, which is UTF-8 encoded equivalent.

http://localhost:8080/springmvc/test?param1=%25

This will work. Refer here for more.

Anish B.
  • 9,111
  • 3
  • 21
  • 41