微信支付
一直报错,build path也不行,网上的方法基本上都试过了。
The method post() from the type HttpClient refers to the missing type ClientProtocolException
The method getContent() from the type HttpClient refers to the missing type ParseException
httpClient.post()报错,有没有人知道怎么解决
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- CSDN专家-sinJack 2021-08-16 10:25关注
不知道你用的是什么依赖。httpClient是http请求客户端对象,执行请求方法是通过HttpPost或者HttpGet对象。
参考: httpclient post方法【亲测可用】_wzder-CSDN博客_httpclient post 很多代码都是根据需求来搞代码的。很早之前的就是给app写的接口,主要项目采用的是基础RMI的项目,服务层不能暴露给外网访问,所以需要给App写转发接口,让App调用其他平台的(内网)接口,重定向很简单的的,但是需要接受其他平台的返回的json。主要使用的httpClient的post方法:直接上代码添加依赖:<!--httpcomponents的包--><depende... https://blog.csdn.net/wt520it/article/details/86551236?utm_source=app&app_version=4.13.0HttpClient client = new DefaultHttpClient(); StringEntity entity = new StringEntity(json.toString()); entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded")); HttpPost post = new HttpPost(urlString); post.setHeader("Accept", "application/json"); post.setHeader("Content-Type", "application/json"); post.setEntity(entity); HttpResponse response = client.execute(post); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { strResult = EntityUtils.toString(response.getEntity(), HTTP.UTF_8); }else{}
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 echarts动画效果失效的问题。官网下载的例子。
- ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
- ¥15 Attention is all you need 的代码运行
- ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
- ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
- ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
- ¥30 关于<main>标签页面跳转的问题
- ¥80 部署运行web自动化项目
- ¥15 腾讯云如何建立同一个项目中物模型之间的联系
- ¥30 VMware 云桌面水印如何添加