1.导入jar包

<dependency>
	<groupId>org.apache.httpcomponents</groupId>
	<artifactId>httpclient</artifactId>
	<version>4.5.5</version>
</dependency>

post请求

public static String send(Map<String, String> textParams, Map<String, byte[]> byteParams) throws IOException {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost(Constant.taobaoUrl);
        HttpEntity content = getContent(textParams, byteParams);
        httpPost.setEntity(content);
        CloseableHttpResponse response = httpClient.execute(httpPost);
        HttpEntity responseEntity = response.getEntity();
        String result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
		response.close();
		return result;
}

发送自定义数据

String data = "数据";
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("https://dh.shiwan123.com/udid/sw/mqq");
//设置发送数据
ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes());
InputStreamEntity reqEntity = new InputStreamEntity(in);
httpPost.setEntity(reqEntity);
CloseableHttpResponse response = httpClient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
String result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
response.close();
Header location = response.getFirstHeader("Location");