JasperReports 报告未在 Spring MVC 应用程序中弹出
我在我的 springMVC 网站中集成了 JasperReports。 它在我的本地系统中运行良好,但是当我将该网站上传到服务器时,会生成报告,但它不会像在我的本地系统中弹出那样弹出。
我正在使用 iReport 4.1
在上传网站之前我还更改了报告的路径。 报告在目标文件夹中生成,但不会自动显示。
这是我的代码:
jasperReport = JasperCompileManager.compileReport("C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\CallCenterRev\\reports\\AttendanceReport.jrxml");
//JasperFillManager.fillReportToFile("D:\\reports\\test.jasper", jasperParameter, rsss);
jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, rsss);
//JasperPrintManager.printReport(jasperPrint,true);
JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\CallCenterRev\\reports\\AttendanceReport.pdf");
// new mainpage(getTitle());
if ((new File("C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\CallCenterRev\\reports\\AttendanceReport.pdf")).exists()) {
Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\CallCenterRev\\reports\\AttendanceReport.pdf");
p.waitFor();
I integrated JasperReports in my springMVC website.
It was running fine in my local system but when I upload that website to server report is getting generated but it is not popping up as it was popping up in my local system.
I'm using iReport 4.1
Before uploading website I also change path for report.
Report is generated at destination folder but it is not displayed automatically.
This is my code:
jasperReport = JasperCompileManager.compileReport("C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\CallCenterRev\\reports\\AttendanceReport.jrxml");
//JasperFillManager.fillReportToFile("D:\\reports\\test.jasper", jasperParameter, rsss);
jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, rsss);
//JasperPrintManager.printReport(jasperPrint,true);
JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\CallCenterRev\\reports\\AttendanceReport.pdf");
// new mainpage(getTitle());
if ((new File("C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\CallCenterRev\\reports\\AttendanceReport.pdf")).exists()) {
Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\CallCenterRev\\reports\\AttendanceReport.pdf");
p.waitFor();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先为什么你使用绝对路径。我认为你应该使用相对路径(ServletContext.getRealPath())。
其次,此代码的用途
当然不会在网络浏览器中显示。要在浏览器中查看报告,请将 pdf 写入 http servlet 响应并相应地设置 http 标头。
First why you are using absolute path.I think you should use relative path (ServletContext.getRealPath()).
Second ,What is for this code
It will not show in web browser ofcourse.For viewing report in browser write pdf to http servletresponse and set http headers accordingly.
如果你使用 spring 3 这可能会有所帮助
If u r using spring 3 this might help