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