HttpPost httpPost = new HttpPost(***);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addTextBody("account",*** );
builder.addTextBody("password",*** );
HttpEntity multipart = builder.build();
String responseJson = HttpUtil.postSet(multipart, httpPost);
/***
*
* @Description post请求
* @Date 14:35 2020/9/25
* @Param [stringBuilder, params]
* @return java.lang.String
**/
public static String postSet(HttpEntity params, HttpPost httpPost) throws IOException {
httpPost.setEntity(params);
CloseableHttpClient client = HttpClients.createDefault();
CloseableHttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
if (entity != null) {
String result = EntityUtils.toString(entity, "UTF-8");
return result;
}
return null;
}