httpclient post 参数
public static void main(String args[]) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); String url = "http://localhost:8888/QueryUser"; HttpPost post = new HttpPost(url); String name= "mike"; JSONObject arg = new JSONObject().element("age", 44).element("job", "cooker")); String queryCase = "name=" + name+ "&&arg=" + arg; StringEntity reqEntity = new StringEntity(queryCase); System.out.println(reqEntity); reqEntity.setContentType("application/x-www-form-urlencoded"); post.setEntity(reqEntity); HttpResponse response = client.execute(post); if (response.getStatusLine().getStatusCode() == 200) { HttpEntity entity = response.getEntity(); String message = EntityUtils.toString(entity, "utf-8"); System.out.println(message); } else { System.out.println("请求失败"); } }