public void finishNotice(String url ,Map<String, String> paraMap){
// 创建Httpclient对象
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
String resultString = "";
Integer status=null;
String msg="";
String problemCode="";
try {
// 创建Http Post请求
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json;charset=UTF-8");
// 创建参数列表
if (paraMap != null) {
// List<NameValuePair> paramList = new ArrayList<>();
for (String key : paraMap.keySet()) {
// paramList.add(new BasicNameValuePair(key, paraMap.get(key)));
if(key.equals("problemCode")){
problemCode = paraMap.get(key);
}
}
// 模拟表单
// UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
// httpPost.setEntity(entity);
//json格式传参
String param=JSON.toJSONString(paraMap);
httpPost.setEntity(new StringEntity(param));
}
// 执行http请求
response = httpClient.execute(httpPost);
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
JSONObject jsonObject = JSON.parseObject(resultString);
status = (Integer) jsonObject.get("status");
msg= (String) jsonObject.get("msg");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}