V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ilovemo
V2EX  ›  问与答

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

  •  
  •   ilovemo · 2021-10-03 14:53:39 +08:00 · 670 次点击
    这是一个创建于 907 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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);

    求解决方案,
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3486 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:03 · PVG 19:03 · LAX 04:03 · JFK 07:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.