开发者

Jasper report pdf name problem

I am creating pdf report in spring mvc 3 using dynamic jasper report. I am setting these headers before writting report to stream.

response.setHeader("Content-Disposition", "inline; filename=" + fileName);
response.setContentType("application/pdf");

Report is generated and display correctly in browser but it miss开发者_JAVA百科es its name when I try to save it, I set name here fileName.

response.setHeader("Content-Disposition", "inline; filename=" + fileName);

What could be the issue.


With attachment, the file will be served with the provided name properly. When inline, browsers seem to ignore filename, and usually give the servletname part of the URL as default name when saving the inline contents.

You could try mapping that URL to an appropriate filename, if that is suitable. For example, with <servlet-mapping>. I'm not familiar with spring mvc, so maybe there's an equivalent.

Here's a SO related question: Securly download file inside browser with correct filename

You may also find this link useful: Filename attribute for Inline Content-Disposition Meaningless?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜