zoukankan      html  css  js  c++  java
  • Spring MVC 文件下载时候 发现IE不支持

    @RequestMapping("download")
        public ResponseEntity<byte[]> download(Long fileKey) throws IOException {
            HttpHeaders headers = new HttpHeaders();
            String fileName=new String(massMessage.getFileName().getBytes("UTF-8"),"iso-8859-1");
            headers.setContentDispositionFormData("attachment", fileName);
            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
            byte[] data = new byte[2];//要下载的数据流
            return new ResponseEntity<byte[]>(data, headers, HttpStatus.CREATED);
        }

    下载时提示:

    下载时提示ie无法打开该站点,请求的站点不可用或找不到

    类似信息

    修改为下面的就OK了,主要是HttpStatus.CREATED修改为HttpStatus.OK

    原因是IE 不支持201的状态码,修改为200就行了

    @RequestMapping("download")
        public ResponseEntity<byte[]> download(Long fileKey) throws IOException {
            HttpHeaders headers = new HttpHeaders();
            String fileName=new String(massMessage.getFileName().getBytes("UTF-8"),"iso-8859-1");
            headers.setContentDispositionFormData("attachment", fileName);
            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
            byte[] data = new byte[2];//要下载的数据流
            return new ResponseEntity<byte[]>(data, headers, HttpStatus.OK);
        }
  • 相关阅读:
    fork子进程
    多输入使用多线程
    多输入select
    多输入之轮询
    开启telnet
    slickedit编译调试linux应用程序
    电子书框架
    通用Makefile
    STDIN_FILENO和stdin
    libiconv交叉编译提示arm-none-linux-gnueabi-gcc
  • 原文地址:https://www.cnblogs.com/ranger2016/p/3842274.html
Copyright © 2011-2022 走看看