【发布时间】:2011-09-12 07:40:00
【问题描述】:
我正在尝试将 JSON 发送到我的服务器并作为结果检索 JSON。 比如发送用户名和密码,取回token等内容。
这就是我为发送的 HTTP 请求所做的。我现在如何检索同一请求中的内容?
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost("http://192.168.1.5/temp/test.php");
List<NameValuePair> value = new ArrayList<NameValuePair>();
value.add(new BasicNameValuePair("Name", jsonStr));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(value);
request.setEntity(entity);
HttpResponse res = client.execute(request);
String[] status_String=res.getStatusLine().toString().trim().split(" ");
//String hd=res.getFirstHeader("result").toString();
//System.out.println("Res=" + res);
Log.e("tag", ""+res.toString());
if(status_String[1].equals("200")){
isDataSent=true;
【问题讨论】:
标签: android json httpclient http-post