httpClient.post()报错,有没有人知道怎么解决

微信支付
一直报错,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
img

img

img

不知道你用的是什么依赖。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.0

HttpClient 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{}

你处理异常了吗