HttpClient结合PostMethod调用接口

 

解决方法:

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());

最新文章

  1. arcgis api for js入门开发系列一arcgis api离线部署
  2. 用ORBSLAM2运行TUM Dataset数据集
  3. [转]sed命令详解
  4. C# 使用IEnumerable,yield 返回结果,同时使用foreach时,在循环内修改变量的值无效(二)
  5. VS2013无调试信息
  6. [转]关于网络通信,byte[]和String的转换问题
  7. 【转】VS2010中 C++创建DLL图解
  8. [转] 在Linux平台使用mhVTL虚拟化磁带库
  9. crossplatform---bower解决js的依赖管理
  10. ANSI是什么编码?
  11. 笔记本PS/2键盘无法使用,试下这个方法
  12. css中auto的用法
  13. Ionic App 启动时报Application Error - The connection to the server was unsuccessful
  14. Leaflet_创建地图(2017-10-20)
  15. 登录sqlplus 后,显示问号 ????
  16. mapreduce中控制mapper的数量
  17. URI -URL-URN区别
  18. zend framework分析总结[转]
  19. SVN出现xcrun: error: invalid active developer path(Mac)
  20. logging- 日志记录

热门文章

  1. 基于Java+Selenium的WebUI自动化测试框架(四)-----设置监听类
  2. mnist数据的预测结果以及批量处理
  3. 文件操作中file.seek()方法
  4. 通用编程语言 Dragon
  5. VFD 时钟(VFD Clock with STM8 v2.0)
  6. KM 最大权匹配 UVA 1411/POJ 3565
  7. Ftp客户端需要TSL功能的文件上传
  8. 一些VMware vCenter Appliance的默认用户名和密码
  9. 【源码拾遗】从vue-router看前端路由的两种实现
  10. Bacteria (Gym - 101911C)