httpclient的post请求遇到301怎么办

2025-04-05 09:59:34
推荐回答(1个)
回答1:

CloseableHttpClientclient=HttpClients.createDefault();HttpPosthttpPost=newHttpPost("你要post的地址");httpPost.setHeader("Content-type","application/json");//header设置Entityentity=newStringEntity(json,"utf-8");httpPost.setEntity(entity);HttpResponseresponse=httpClient.execute(httpPost);