我正在尝试从特定目录下载文件,当我测试服务时,后端的一切正常,但是当我从前端尝试它时,我收到此错误并且弹出/向上保存不显示。这是我的弹簧启动后端代码:
我的前角5角看起来像这个enter image description here
在你之后
respHeaders.setContentType(MediaType.APPLICATION_PDF);
尝试添加此:
respHeaders.add("Content-Disposition", "attachment; filename=\"file.pdf\"");