前端获取不到header里面的文件名 后端代码
java
try (OutputStream outputStream = res.getOutputStream()) {
            res.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode((String) fileList.get(0).get("fileName"), "utf-8"));
            res.setHeader("Content-Type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
           
            // 将字节数组写入输出流
            outputStream.write((byte[]) fileList.get(0).get("bytes"));
            // 刷新输出流,确保所有数据都被发送出去
            outputStream.flush();
        } catch (IOException e) {
            // 异常处理
            throw new SystemException(500, "导出word文件失败!");
        }
加上
java res.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
本文作者:Weee
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!