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 数组

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

发布了66 篇原创文章 · 获赞 8 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/qq_37889636/article/details/81044888