已有json请求参数
String url = "http://192.168.15.23:8180/ab_admin?action=policy_check"; CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(url); StringEntity entity = new StringEntity(param, "utf-8");//解决中文乱码问题 entity.setContentEncoding("UTF-8"); entity.setContentType("application/json"); httpPost.setEntity(entity); CloseableHttpResponse response = httpclient.execute(httpPost); String respContent = ""; if (response.getStatusLine().getStatusCode() == 200) { HttpEntity he = response.getEntity(); respContent = EntityUtils.toString(he, "UTF-8"); return respContent; }
时间: 2024-11-20 20:12:37