Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
108 views
in Technique[技术] by (71.8m points)

java - Sending % through @RequestParam in Spring

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) {
  ...
}
question from:https://stackoverflow.com/questions/66061770/sending-through-requestparam-in-spring

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...