如何更改JasperReport的实际名称? [英] How can I change a JasperReport's actual name?

查看:123
本文介绍了如何更改JasperReport的实际名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java生成已编译的jasper报告的PDF。预编译报告的名称为statsReport。报告生成正确。问题是什么时候有时间来保存文件。我尝试通过JasperPrint对象更改报告名称(jasperPrint.setName('statsReport_20110718.pdf'))。我这样做是因为用户期望文件使用特定于语言的名称(法语或英语)和日期保存。

I am using Java to generate a PDF of a compiled jasper report. The pre-compiled report has the name 'statsReport'. The report generates properly. The problem is when comes the time to save the file. I try changing the report name through the JasperPrint object (jasperPrint.setName('statsReport_20110718.pdf')). I do this because the user's expecting the file to save with a language specific name (French or English) and the date.

使用Firefox设置在执行操作前提示(在阅读器中打开或另存为文件),我传递的文件名按预期使用('statsReport_20110718.pdf')。问题是浏览器设置是在Firefox / IE中自动打开pdf。报告正确打开,但当用户想要保存文件时,它会显示预编译的jasper报告名称('statsReport')。

When using Firefox set to prompt before executing an action (Open in reader or Save as file), the filename I passed is used as expected ('statsReport_20110718.pdf'). The problem is when the browser setting is to open pdf automatically in Firefox/IE. The report opens correctly but when the user wants to save the file, it displays the pre-compiled jasper report name ('statsReport').

JasperReport类没有可能有用的setName方法。

JasperReport class does not have a setName method that might have been useful.

有没有人有任何想法?

理查德

推荐答案

在servlet响应中设置HTTP标头,如:

Set a HTTP Header in your servlet response like:

Content-Disposition: filename=statsReport_20110718.pdf

这篇关于如何更改JasperReport的实际名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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