java如何發送httphead請求?
實現思路就是先定義請求頭內容,之后進行請求頭設置。;定義請求頭;LinkedHashMap<String,String> headers = new LinkedHashMap<String,String>();;headers.put("Content-type","text/xml");;headers.put("Cache-Control", "no-cache");;headers.put("Connection", "close");;給HttpPost 設置請求頭;
HttpPost httpPost = new HttpPost("地址");;if (headers != null) {;for (String key : headers.keySet()) {;httpPost.setHeader(key, headers.get(key));;};};備注:只需要在map中設置相應的請求頭內容即可。根據實際需要修改即可