zoukankan      html  css  js  c++  java
  • RequestBody 和RequestEntity使用

    1 HttpClient client = new HttpClient();
    2 PostMethod post = new PostMethod(redirectUrl);
    3         Part[] parts = {
    4                 new StringPart("user", “aaa”),
    5                 new StringPart("password", "bbb")
    6                 };
    7         post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
    8 client.executeMethod(post);
    9 String result = post.getResponseBodyAsString();
    1 HttpClient client = new HttpClient();
    2 PostMethod post = new PostMethod(redirectUrl);
    3         NameValuePair[] pairs = {
    4             new NameValuePair("user", “aaa”),
    5                         new NameValuePair("password", “bbb”)
    6                         };
    7         post.setRequestBody(pairs);
    8 client.executeMethod(post);
    9 String result = post.getResponseBodyAsString();
  • 相关阅读:
    豆豆
    艺术家
    姐姐
    书名与歌名
    MySQL
    杂文
    武侠
    青年诗人
    那些歌
    传世
  • 原文地址:https://www.cnblogs.com/leavescy/p/11761864.html
Copyright © 2011-2022 走看看