【发布时间】:2011-08-04 09:36:22
【问题描述】:
public class HTTPPoster {
public static HttpResponse doPost(String url, JSONObject c) throws ClientProtocolException, IOException
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
HttpEntity entity;
StringEntity s = new StringEntity(c.toString());
s.setContentEncoding((Header) new BasicHeader(HTTP.DEFAULT_CONTENT_CHARSET, "application/json"));
entity = s;
request.setEntity(entity);
HttpResponse response;
response = httpclient.execute(request);
return response;
}
}
这是代码,但在 response = http.client.execute(request) 上没有得到响应。我找不到原因。
【问题讨论】:
-
对不起 Demet 我很想回答你的问题,但你给我们的工作不多。以最礼貌的方式写下那张纸条。仅仅要求代码并不是最好的行为。什么水
-
您得到的回应是什么?它是空的吗?是否抛出异常?
标签: android httpclient http-post