zoukankan      html  css  js  c++  java
  • ie 导出不行,不兼容问题,或只出现后缀文件无法识别

    // 下载模板
    @RequestMapping("/download")
    @ResponseBody
    public ResponseEntity<byte[]> download(HttpServletRequest request)throws IOException {

    String path="mouldmb.xls";
    File file = new ClassPathResource(path).getFile();// path是根据日志路径和文件名拼接出来的
    String filename="客户资料导入模板"+".xls";
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
    headers.setContentDispositionFormData("attachment", new String(filename.getBytes("utf-8"),"iso8859-1"));
    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED); //状态码是201,ie10,11不识别  改为HttpStatus.OK  但名称会乱码
    }

    可能是与操作系统有关系

    将headers.setContentDispositionFormData("attachment", new String(filename.getBytes("utf-8"),"iso8859-1")); 

    改为

    headers.setContentDispositionFormData("attachment", new String(filename.getBytes("GBK"),"iso8859-1")); 

  • 相关阅读:
    TCP同步与异步
    C#委托与事件
    线程
    C# 多人聊天程序
    vs启动错误
    记住我的痛苦
    C#命名空间与类名的冲突
    C#调试类
    linux ifconfig命令参数及用法详解linux查看配置网卡命令
    B/S架构
  • 原文地址:https://www.cnblogs.com/cbdd/p/5595805.html
Copyright © 2011-2022 走看看