【发布时间】:2017-04-19 12:15:41
【问题描述】:
我有一个 json 字符串,我想将它传递给 POST 方法。但是 'execute' 和 'executeMethod ' 抛出错误如下:
“HttpClient 类型中的方法 execute(HttpUriRequest) 不适用于参数 (PostMethod)”。我已经包括了依赖项。
我的代码:
StringRequestEntity requestEntity = new StringRequestEntity(
json-string,
"application/json",
"UTF-8");
PostMethod postMethod = new PostMethod("myUrl");
postMethod.setRequestEntity(requestEntity);
HttpResponse response = httpclient.execute(postMethod);
有没有其他方法可以做到这一点?请帮忙。提前致谢
【问题讨论】: