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;
}
java http post from表单提交
最新推荐文章于 2024-08-18 21:36:31 发布