【发布时间】:2017-04-19 16:21:44
【问题描述】:
我对 PDF base64 字符串有疑问,我不知道为什么文件名没有出现在 pdf 查看器中,而不是文件名我有一组我认为与字节数组相关的字符。
服务器端
@RequestMapping(value = "/report", produces = "application/pdf")
public @ResponseBody HttpEntity<byte[]> reportPdf(HttpServletRequest request, HttpServletResponse response)
...
byte[] document = report.getBytes(StandardCharsets.UTF_8);
...
HttpHeaders header = new HttpHeaders();
header.setContentType(new MediaType("application", "pdf"));
header.set("Content-Disposition", "inline; filename=asdfasdfasdf.pdf");
header.setContentLength(document.length);
return new HttpEntity<byte[]>(document,header);
我正在通过 JavaScript 应用程序调用此 REST 服务,但我不知道如何控制此文件名。
谁能给我任何线索?在这种情况下可以更改这个新文件名吗?
问候!
【问题讨论】: