public static String httpExecute( List<BasicNameValuePair> pairList, String url)
{
try {
HttpPost httpPost = new HttpPost(url);
CloseableHttpClient client = HttpClients.createDefault();
String respContent = null;
httpPost.setEntity(new UrlEncodedFormEntity(pairList,"utf-8"));
HttpResponse resp = client.execute(httpPost);
if (resp.getStatusLine().getStatusCode()==200)
{
HttpEntity he = resp.getEntity();
respContent = EntityUtils.toString(he,"utf-8");
}
return respContent;
}catch (Exception e) {
log.error("http post error: " + e);
}
return null;
}
来源:CSDN
作者:BMKB
链接:https://blog.csdn.net/q446002320/article/details/104511487