这是我的HttpClient请求:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.***.**/***/***_***.php");
String HTML = "";
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("from", contactName));
nameValuePairs.add(new BasicNameValuePair("msg", message));
nameValuePairs.add(new BasicNameValuePair("sent", time_sent));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HTML = "How?";
} catch (ClientProtocolException e) {} catch (IOException e) {}
如何使用请求的源代码填充HTML字符串?
答案 0 :(得分:5)
HttpResponse response = httpclient.execute(httppost);
HTML = EntityUtils.toString(response.getEntity());
答案 1 :(得分:4)
你去了:
String html = org.apache.http.util.EntityUtils.toString( response.getEntity() );
答案 2 :(得分:1)
您可以通过阅读httpresponse.getEntity().getContent();
不知何故,我认为这可能无法解答您的问题,因为您使用“源代码”一词。