2

I have a controller with a RequestParam as a String, which is BASE64 encoded, and it includes many times the "+" character (something like "domain.com/request?code=sdfesdfd+23fewrfr3"). When I try to print the 'code' value whitin the controller method body, it prints the value replacing the "+" for a space " " (in the example, "sdfesdfd 23fewrfr3"). How can I avoid having this problem?

AndraD
  • 2,830
  • 6
  • 38
  • 48

2 Answers2

2

Run the string through the URLEncoder if you can...

http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html

... if you can't do that, try using percent encoding....

http://en.wikipedia.org/wiki/Percent-encoding

rgb130
  • 90
  • 8
-1

A replace of all spaces with '+'?

 code.replaceAll(" ", "+");
Καrτhικ
  • 3,833
  • 2
  • 29
  • 42