search

Home  >  Q&A  >  body text

java http 请求参数都需要URLEncoder.encode吗

如标题~

PHPzPHPz2910 days ago480

reply all(4)I'll reply

  • 怪我咯

    怪我咯2017-04-18 10:33:33

    Not all parameters need to be encoded. Using URLEncoder是一种解决方式,但是并不是必须的选择。
    但是如果你的参数中带有URI保留字,那你必须要使用URLEncoder。比如你的参数中带有/&?=...这类保留字,如果你不编码那解析URL to solve Chinese garbled characters is definitely not the result you expect.
    RFC 3986 2.2. Reserved Characters

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 10:33:33

    Prevent Chinese garbled characters, you can use it or not

    reply
    0
  • 迷茫

    迷茫2017-04-18 10:33:33

    The browser will automatically do URLEncoder.encode once, no need to manually URLEncoder.encode

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:33:33

    In the Android code, I use android.net.Uri.encode(). If I am not sure whether there are special characters in the parameters, I just add them. It is not complicated.

    reply
    0
  • Cancelreply