V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
ilovemo
V2EX  ›  问与答

Resttemplate 表单提交获取文件,返回 302 , Transfer-Encoding:"chunked",获取到数据为 null

  •  
  •   ilovemo · Oct 3, 2021 · 1506 views
    This topic created in 1681 days ago, the information mentioned may be changed or developed.
    https://www.poi86.com/poi/download_street_geojson/22054.html 这个页面资源,通过 Resttemplate 获取,Resttemplate 表单提交获取文件,返回 302,Transfer-Encoding:"chunked",获取到数据为 null,这是为啥啊,这是我核心代码:


    //设置为 form 方式
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    headers.set("Accept-Encoding","gzip, deflate, br");
    headers.set("Content-Length","27");
    headers.set("Connection","keep-alive");
    //设置请求参数
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.add("streetid", adcode);
    parameters.add("Captcha", captcha);//https://www.poi86.com/poi/download_street_geojson/25357.html
    HttpEntity<MultiValueMap<String, String>> multiValueMapHttpEntity = new HttpEntity<>(parameters, headers);
    ResponseEntity<byte[]> result = restTemplate.postForEntity(GEO_URL_PREFIX + "/GeoJson/Street", multiValueMapHttpEntity, byte[].class);

    求解决方案,
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3412 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 11:58 · PVG 19:58 · LAX 04:58 · JFK 07:58
    ♥ Do have faith in what you're doing.