这是我的代码,数组中的 fileByte,其中包含 PDF 的内容。但是,该文件已损坏,我无法从中读取。这里有什么问题?谢谢!
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.addHeader("Content-Disposition", "attachment;filename=test.pdf");
ServletOutputStream outputStream = response.getOutputStream();
response.setContentType("application/pdf");
response.setContentLength(fileByte.length);
outputStream.write(fileByte);
outputStream.flush();
outputStream.close();