HttpURLConnection调用Get请求引发的参数不全问题,&符号一定要转义/&

今天在程序调用的时候,http请求一个get,因为参数里面有&符号,所以接收方一直在报参数不全,最后终于查到了由于url里面包含了&符号,如:

String url = "http://localhost/appid=4&fileIds=aaaa";

正确应为:

String url = "http://localhost/appid=4\\&fileIds=aaaa";

&符号会被认为是后台执行,所以后面的参数就丢了。

猜你喜欢

转载自blog.csdn.net/airyearth/article/details/108649656