如何在Java中通过URL传递JSON数据?

时间:2017-07-12 09:03:38

标签: java

我想通过URL发送一些JSON数据,请任何人告诉我如何做到这一点。 我的网址如下所示:

<div class="wrapper">
  <div class="try1">DUE DILIGENCE EXPIRATION</div>
</div>

1 个答案:

答案 0 :(得分:0)

您可以使用apache.http.client库发送数据:

RequestBuilder rb = RequestBuilder.post();
        rb.setUri(url);
        rb.addHeader("content-type", "application/json");
        rb.addHeader("Accept","*/*");
        rb.setEntity(new StringEntity(jsonString))
CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse httpResponse = httpClient.execute(rb.build());

jsonString在json中的数据