`
zcw_java
  • 浏览: 297250 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Http协议Post请求模拟

 
阅读更多
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://www.test.com/login.aa");

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("name","zhangsan")); 
nameValuePairs.add(new BasicNameValuePair("pwd","123456")); 
try{
    post.setEntity(new UrlEncodedFormEntity(nameValuePairs ));
    HttpResponse response = client.execute(post);
    System.out.println(EntityUtils.toString(response.getEntity()));
}catch(Exception e){
    e.printStackTrace();
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics