java–Http get exception目标主机在ICS上不能为null

java–Http get exception目标主机在ICS上不能为null,第1张

概述我在ICS上遇到这个例外,而在2.2上运行正常.java.lang.IllegalStateException:Targethostmustnotbenull,orsetinparameters.scheme=null,host=null,path=http://maps.googleapis.com/maps/api/geocode/json?latlng=32.0692342,34.7952296&sensor=true这是我的代码:

我在ICS上遇到这个例外,而在2.2上运行正常.

java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=http://maps.GoogleAPIs.com/maps/API/geocode/Json?latlng=32.0692342,34.7952296&sensor=true

这是我的代码:

        httpGet request = new httpGet(URLEncoder.encode(requestUrl, "UTF-8"));        httpResponse response;        response = mhttpClIEnt.execute(request);

解决方法:

删除URLEncoder.encode调用,不需要它

需要对url参数进行编码,例如:

String url = "http://maps.GoogleAPIs.com/maps/API/geocode/Json?latlng="+URLEncoder.encode("32.0692342,34.7952296")+"&sensor="+URLEncoder.encode("true")
总结

以上是内存溢出为你收集整理的java – Http get exception目标主机在ICS上不能为null全部内容,希望文章能够帮你解决java – Http get exception目标主机在ICS上不能为null所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1115503.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存