java http 请求参数都需要URLEncoder.encode吗
PHPz
PHPz 2017-04-18 10:31:33
0
4
471

如标题~

PHPz
PHPz

学习是最好的投资!

reply all(4)
刘奇

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

Ty80

Prevent Chinese garbled characters, you can use it or not

迷茫

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

巴扎黑

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template