Why does apache-commons lib encode space as + not like% 20?

I use URLCodec from Apache Commons Codec to encode the url, but it encodes the space as + NOT like %20

why? and what is the solution?

+6
java apache-commons url-encoding apache-commons-codec
source share
3 answers

See this related question.

Of course, you can always do url.replace("+", "%20"); if you need it (after coding)

+3
source share

Because + is an equally valid way to encode a space. What are you trying to "solve"?

+2
source share

URLCodec encodes material corresponding to the submitted form, which does not match the percentage encoding the URL. There are more explanations in this matter.

See this question on how you should encode your URL.

+2
source share

All Articles