HTTPPOST使用

一般httppost都是结合HttpClients使用

CloseableHttpResponse response = null;

CloseableHttpClient client = null;


HttpPost httpPost = new HttpPost(url);    //需要请求的url

httpPost.setEntity(entityParams);   //放入需要传的值

client = HttpClients.createDefault();   // new 个 client

response = client.execute(httpPost);   //发送请求 并接收返回值

byte[] bytes = EntityUtils.toByteArray(response.getEntity());   //将返回值转为bytes 数组

// 后边就是根据情景对返回值进行具体的操作

你可能感兴趣的:(后台)