HttpClient Post Form data and get Response String
2016-08-23 10:59
351 查看
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(访问网络) get方式,post方式。返回值有String,InputStream,byte[]
- HttpClient(访问网络) get方式,post方式。返回值有String,InputStream,byte[]
- Http client to POST using multipart/form-data
- httpclient 在获取返回值时,使用getResponseBodyAsString触发警告的问题
- [c#][Windows 10 | Windows 10 mobile | Windows Phone] HttpClient 实现form-data POST上传请求
- Http client to POST using multipart/form-data
- POST a string and an image in one request using HttpClient
- go http.Get请求 http.Post请求 http.PostForm请求 Client 超时设置
- HttpClient(访问网络) get方式,post方式。返回值有String,InputStream,byte[]
- java httpclient multipart/form-data 方式post
- Get json formatted string from web by sending HttpWebRequest and then deserialize it to get needed data
- Android HttpClientConnection Get and Post
- Node(6) Accessing GET and POST data using http.ServerRequest
- android向服务器上传multipart/form-data文件(upload using multipart post using httpclient in android)
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别 [转]
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别 [转]
- How to get response content with specified post data by post method
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别
- 几个http请求相关的函数 HttpWebRequest: Post , Get ; PostAndRedirect
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别 [转]