Issue
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) {
...
}
Solution
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.
Answered By - Anish B.
Answer Checked By - Pedro (JavaFixing Volunteer)