maven引用:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
example:
String resultJson = null;
CloseableHttpClient httpclient = HttpClients.createDefault();
String url = "http://xxxx";
HttpPost httpPost = new HttpPost(url);
List <NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("qqq", "xx"));
httpPost.setEntity(new UrlEncodedFormEntity(params,Charset.forName("UTF-8")));
CloseableHttpResponse response = httpclient.execute(httpPost);
HttpEntity entity = response.getEntity();
String entityStr = EntityUtils.toString(entity);
JSONObject jsonObject = JSONObject.fromObject(entityStr);