2 qwetyu qwetyu 于 2013.11.07 14:38 提问

各位大神帮我解决下安卓用post方法向服务器传值,状态输出以及下面的输出都没有打印

private void postValues (JSONObject param) throws ClientProtocolException, IOException{
String url = "http://app.taosame.com/index.php/user/login.html";
System.out.println(url);
HttpPost request = new HttpPost(url);
// 绑定到请求 Entry
StringEntity se;
se = new StringEntity(param.toString());
System.out.println("StringEntity长度------->"+se.getContentLength());
request.setEntity(se);
System.out.println("是否已经加入道Entity"+se);
// 发送请求
HttpResponse httpResponse = new DefaultHttpClient().execute(request);
System.out.println("状态-s------------------>"+httpResponse.getStatusLine().getStatusCode());
// 得到应答的字符串
String retSrc = EntityUtils.toString(httpResponse.getEntity());
System.out.println("返回值信息------------->"+retSrc);
if(retSrc.equals("error")){
Toast.makeText(MainActivity.this, "用户名或密码错误", Toast.LENGTH_LONG).show();
}
else if (retSrc.equals("error1")){
Toast.makeText(MainActivity.this, "没有该用户", Toast.LENGTH_LONG).show();
}
else if (retSrc.equals("0")) {
Toast.makeText(MainActivity.this, "请输入用户名和密码", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(MainActivity.this, "登陆成功", Toast.LENGTH_LONG).show();
}
// 生成 JSON 对象
//JSONObject result = new JSONObject( retSrc);
//String token = result.get("token");
}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!