DefaultHttpClient httpClient = new DefaultHttpClient(httpParams);
httpClient.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false);
HttpPost httpPost=new HttpPost(url);
try
{
if(nvps.size()>0){httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));}
HttpResponse response=httpClient.execute(httpPost);
if(response.getStatusLine().getStatusCode()== HttpStatus.SC_OK)//判断是否正确执行
{
//获取到网络请求回来的输入流;
returnString=EntityUtils.toString(response.getEntity());//InputStream is=response.getEntity().getContent();
}
}
catch (Exception e)
{
e.printStackTrace();
}
上面代码执行老是抛出下面错误:
06-18 23:54:39.045 6017-6131/com.logohoo.manstore.app W/System.err﹕ org.apache.http.client.ClientProtocolException
06-18 23:54:39.045 6017-6131/com.logohoo.manstore.app W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:585)
06-18 23:54:39.055 6017-6131/com.logohoo.manstore.app W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:506)
06-18 23:54:39.055 6017-6131/com.logohoo.manstore.app W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:484)
06-18 23:54:39.055 6017-6131/com.logohoo.manstore.app W/System.err﹕ at com.logohoo.manstore.app.HttpAdapter.postStringForm(HttpAdapter.java:78)
06-18 23:54:39.065 6017-6131/com.logohoo.manstore.app W/System.err﹕ at com.logohoo.manstore.app.LoginActivity$2.run(LoginActivity.java:66)
请问怎么解决?问题在哪里?
------解决思路----------------------
1,先在浏览器测试下地址看能否访问,
2,1如果没问题的话就是你httppost构造的有问题了
------解决思路----------------------
不知道你具体的怎么构造的,给你个例子看看。