httpclient4 post 以json方式传参数
来源:互联网 发布:cpu淘宝e5水多深 编辑:程序博客网 时间:2024/05/16 04:43
public static String sendSetHeaderGetRequestByPostForJson(String url,Map<String,String> map,Map<String,Object> psotMap/*String appUid,String listMsgIds*/ ) throws Exception{BufferedReader buffer=null;String result="";try { CloseableHttpClient httpclient = HttpClients.createDefault(); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(3000).setConnectTimeout(3000).build();//设置请求和传输超时时间 HttpPost httpPost = new HttpPost(url); httpPost.setConfig(requestConfig); httpPost.addHeader(HTTP.CONTENT_TYPE, "application/json"); httpPost.addHeader(HTTP.CONTENT_TYPE, "text/json"); httpPost.setHeader("appKey", map.get("appKey")); httpPost.setHeader("nonce", map.get("nonce")); httpPost.setHeader("timestamp", map.get("timestamp")); httpPost.setHeader("signature", map.get("signature")); JSONObject obj=JSONObject.fromObject(psotMap); StringEntity se = new StringEntity(obj.toString()); se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); httpPost.setEntity(se); CloseableHttpResponse response= httpclient.execute(httpPost); buffer=new BufferedReader(new InputStreamReader(response.getEntity().getContent(),"utf-8")); result =buffer.readLine(); return result;} catch (Exception e) {e.printStackTrace();}finally{buffer.close();} return null; }
0 1
- httpclient4 post 以json方式传参数
- HttpClient4.3 用post方式传JSON格式字符串参数
- httpclient4 post请求传参数
- java 通过http post方式传参参数json 方式
- 使用window.open打开新窗口,以post方式传参数
- [Android] 以post方式上传参数
- window.open 以post方式传递参数
- http post方式获取json参数
- python使用post方式发送json参数
- httpclient4教程之post参数【九】
- 使用RESTful API以post+json的方式给服务器传数据
- 以Post方式提交并解析json数据
- window.location.href以post方式传递参数
- HttpClient 实现重定向 以表单方式post提交参数
- Window.location.href以post方式传递参数的方法
- Window.location.href以post方式传递参数的方法
- 以Post方式请求
- express 解析post方式下的json参数
- Spring MVC dropdown box example
- Ubuntu Server 添加/删除/修改用户
- Unity3D笔记第十八天——编辑器的拓展
- 神奇的数据建模框架JSONModel
- Git问题:Cannot update paths and switch to branch 'dev' at the same time.
- httpclient4 post 以json方式传参数
- 关于矩阵的用法
- Scheme 博客收藏
- Unity3D笔记第十九天——项目优化策略
- Android,隐藏输入法
- Spring MVC hidden value example
- 构造函数为什么不能是虚函数
- TSM恢复ORACLE数据库速度极慢的问题。
- Unity3D笔记第二十天——3D图形学(网格基础)