我正在使用httpServletResponse返回一个字节数组,并且content-disposition头已经正确设置。而且我获取到的内容也是正确的。但不知何故,文件名变成了undefined.zip。
以下是代码片段:
// set content attributes for the response
response.setContentType("application/octet-stream");
response.setContentLength((int) packageZipFile.length);
// set headers for the response
String headerKey = "Content-Disposition";
String headerValue = "attachment; filename=\"abc.zip\"";
response.setHeader(headerKey, headerValue);
// get output stream of the response
outStream = response.getOutputStream();
outStream.write(packageZipFile);
在浏览器的REST调用响应中,它被正确地设置为如下所示: Content-Disposition:attachment; filename="abc.zip"
请问我做错了什么?先谢谢您的帮助!