下载带有角度5和Spring启动的文件

问题描述 投票:1回答:1

我正在尝试从特定目录下载文件,当我测试服务时,后端的一切正常,但是当我从前端尝试它时,我收到此错误并且弹出/向上保存不显示。这是我的弹簧启动后端代码:

enter image description here

我的前角5角看起来像这个enter image description here

服务:enter image description here

rest spring-boot angular5 downloadfile
1个回答
1
投票

在你之后

respHeaders.setContentType(MediaType.APPLICATION_PDF);

尝试添加此:

respHeaders.add("Content-Disposition", "attachment; filename=\"file.pdf\"");
© www.soinside.com 2019 - 2024. All rights reserved.