• 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);
        }
  • 相关阅读:
    0X01 OWASP WebGoat Splitting
    subprocess
    Python中getopt()函数的使用
    Python3_UDP客户端
    Python3编写TCP客户端
    Python3---pymysql库____操作数据库
    review——database (1)CH8-Relational Database Design
    删除的review——数据库 (1)CH6关系数据理论
    review——C# (15)转换
    review——C# (14)接口
  • 原文地址:https://www.cnblogs.com/ranger2016/p/3842274.html
Copyright © 2020-2023  润新知