PostClient { public void post() throws IOException { HttpResponse response = null; HttpEntity entity = null; CloseableHttpClient httpclient = new DefaultHttpClient(); try { HttpPost post = new HttpPost(url); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("key", "4b441cb500f431adc6cc0cb650b4a5d0")); params.add(new BasicNameValuePair("info", "上海去嘉兴火车")); UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(params, HTTP.UTF_8); post.setEntity(urlEncodedFormEntity); response = httpclient.execute(post); log.info("status:" + response.getStatusLine()); if (response.getStatusLine().getStatusCode() == 200) { entity = response.getEntity(); String result = EntityUtils.toString(entity, "UTF-8"); log.info(result); } } catch (Exception e) { log.error("" + e.getLocalizedMessage()); } finally { if (response != null) { EntityUtils.consume(entity); } } }  void post(); void post2(); void gzip();  }
@Test public void testPost() throws Exception { postClient.post(); }