[Java] 模拟post请求 →→→→→进入此内容的聊天室

来自 , 2019-04-21, 写在 Java, 查看 122 次.
URL http://www.code666.cn/view/f337d999
  1. public void postmethod(PostMethod postMethod, HttpClient client, int i) {
  2.                 String resCode = null;
  3.                 try {
  4.                         client.executeMethod(postMethod);
  5.  
  6.                         int code = postMethod.getStatusCode();
  7.                         if (code == HttpStatus.SC_OK) {
  8.                                 String info = null;
  9.                                 info = new String(postMethod.getResponseBodyAsString());
  10.                         }
  11.                         postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
  12.                         /**
  13.                          * 打印服务器返回的状态
  14.                          */
  15.                         System.out.println("the post return value:" + postMethod.getStatusLine());
  16.                         String typ = postMethod.getStatusLine().toString();
  17.                         /**
  18.                          * 打印结果页面
  19.                          */
  20.                         // String response = new
  21.                         // String(postMethod.getResponseBodyAsString().getBytes("UTF-8"));
  22.                         // /**
  23.                         // * 打印返回的信息
  24.                         // */
  25.                         // System.out.println("the getBytes() xml is:"+response);
  26.                         // //打印返回的信息
  27.                         resCode = postMethod.getResponseBodyAsString();
  28.                         // 释放连接
  29.                 } catch (IOException e) {
  30.                         e.printStackTrace();
  31.                 } finally {
  32.                         postMethod.releaseConnection();
  33.                 }
  34.         }

回复 "模拟post请求"

这儿你可以回复上面这条便签

captcha