这是我的 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 字符串?
最佳答案
HttpResponse response = httpclient.execute(httppost);
HTML = EntityUtils.toString(response.getEntity());
关于java - 如何从 HttpClient HttpResponse 获取源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6824802/