String content = null;
try {
// 创建CloseableHttpClient
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost("请求地址");//地址
httpPost.setHeader("x-tif-paasid", paasId);//请求头
RequestConfig config = RequestConfig.custom().setConnectTimeout("超时时间").build();
httpPost.setConfig(config);
HttpEntity entity = new StringEntity(params, "utf-8"); // 参数设置utf8编码
httpPost.setEntity(entity);
CloseableHttpResponse response = client.execute(httpPost);//消息发送
content = EntityUtils.toString(response.getEntity());//获取返回值
} catch (Exception e) {
e.printStackTrace();
}
return content;
版权声明:本文为weixin_44342481原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。