urlencode - Encoding URL query parameters in Java -


How does a query parameter encode to go to a URL in java? I know, it sounds like a clear and already asked question.

I do not believe in two subtleties:

  1. On the url as "+" or "% 20"? In Chrome, if I type in "http://google.com/foo=?bar me", then Chrome can be encoded with% 20
  2. Is it necessary to encrypt the colon / Right ":" As of% 3b? Not Chrome.

    Note:

    • java.net.URLEncoder.encode does not seem to work, it seems that encoding Submit for the data form. For example, instead of + it encodes the location as + 20 , and the colon which is not necessary.
    • java.net URI does not encode query parameters

      can also help it comply with HTML form encoding application / x-www-form-urlencoded .

        URLNcoder.exode (query, "UTF-8");   

      On the other hand, (which is also known) encodes in space with % 20 . The colon is a reserved character, hence the : colon will remain after the encoding.

Comments