【发布时间】:2014-04-02 06:25:54
【问题描述】:
Java 代码:
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse =httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
网址是这样的:
http://122.180.133.121:84/diogo/api/api.php?class=authenticate&method=login_check¶m={'userpassword':'777','username':'www'}
而logcat的错误是:
java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=http://122.170.103.168:86/diogo/api/api.php?class=authenticate&method=login_check¶m={'userpassword':'123','username':'krunal'}
我已经搜索了很多解决方案,但都在说 http 或 www.. 但我不知道实际问题是什么。只是因为我的服务器IP地址还是什么。?
【问题讨论】:
-
确保其网址有效
-
我已经检查过了..它有效。
-
尝试对 url 进行编码。一个疯狂的猜测
-
检查参数名称或对您的 URL 进行编码。使用 URL.encode()
-
@Raghunandan 我已经通过了编码的网址
标签: android get androidhttpclient