1.httpclient get 方式
HttpGet httpGet = new HttpGet(url);
HttpClient client = new DefaultHttpClient();
HttpResponse response=client.execute(httpGet);
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_Ok){
String content = EntityUtils.toString(response.getEntity);
}
2.httpclient post 方式
HttpPost post= new HttpPost(url);
HttpClient client = new DefaultHttpClient(); ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
list.add(new BasicNameValuePair("name",name));
list.add(new BasicNameValuePair("age",age)); post.setEntity(new UrlEncodedFormEntity(list)); HttpResponse response=client.execute(post);
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_Ok){
String content = EntityUtils.toString(response.getEntity);
}