HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(uri);
List<NameValuePair>list = new ArrayList<NameValuePair>();
NameValuePair pair = new BasicNameValuePair("name", "hh");
list.add(pair);
try {
HttpEntity entity = new UrlEncodedFormEntity(list,HTTP.UTF_8);
post.setEntity(entity);
HttpResponse response = client.execute(post);
if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
String result = EntityUtils.toString(entity, HTTP.UTF_8);
}
} catch (UnsupportedEncodingException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
HttpClient
最新推荐文章于 2025-01-26 17:56:43 发布