解决方法:

HttpClient client = new HttpClient();

PostMethod post = new PostMethod("http://192.168.0.189:8500/short");

post.addRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");// 在头文件中设置转码

post.setRequestHeader("Connection", "close");

NameValuePair[] data = { new NameValuePair("username", this.username), new NameValuePair("passwd", this.passwd))};

post.setRequestBody(data);

client.executeMethod(post);

Header[] headers = post.getResponseHeaders();

int statusCode = post.getStatusCode();

String result = new String(post.getResponseBodyAsString().getBytes());

相关文章:

  • 2022-01-03
  • 2021-09-02
  • 2021-12-28
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
猜你喜欢
  • 2021-11-10
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
相关资源
相似解决方案