设置流回浏览器的Pdf的文件名 [英] Set filename of the Pdf that is streamed back to the browser

查看:339
本文介绍了设置流回浏览器的Pdf的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java Web应用程序,用于创建pdf并将其流式传输回浏览器.

I have a Java webapp creating a pdf and streaming it back to the browser.

 byte[] pdf = report.exportPdfToArray(user);
response.setContentType("application/pdf");
response.setHeader("content-disposition", "inline; filename=\"My.pdf\"");
outStream = response.getOutputStream();
outStream.write(pdf);
outStream.flush();
outStream.close();

执行报告并将其发送回浏览器,但是即使设置了content-disposition,我也无法控制文件名. 我正在使用Jboss 4.2.1.你知道我在想什么吗?

The report is executed and it is sent back to the browser, but I can not control the name of the file even though I set the content-disposition. I am using Jboss 4.2.1. Do you know what am I missing?

编辑:因此,当内容处置为嵌入式时,有什么方法可以设置文件名?

EDIT: So is there any way to set the filename when the content-disposition is inline?

推荐答案

content-disposition:附件....

content-disposition: attachment ....

这篇关于设置流回浏览器的Pdf的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆