码迷,mamicode.com
首页 > Web开发 > 详细

HttpClient Post Form data and get Response String

时间:2016-08-23 11:20:50      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

DefaultHttpClient httpclient = new DefaultHttpClient(); 
HttpPost httpost = new HttpPost("http://xxx/yyy/login"); 

List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("key1", "value1"));  
params.add(new BasicNameValuePair("key2", "value2"));  
		
try {
	httpost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
	HttpResponse response = httpclient.execute(httpost);
	int status = response.getStatusLine().getStatusCode();
	String body = EntityUtils.toString(response.getEntity()); 
} catch (Exception e) {
	e.printStackTrace();
}  

 

HttpClient Post Form data and get Response String

标签:

原文地址:http://www.cnblogs.com/webglcn/p/5798429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!