java JasperReports报告没有在Spring MVC应用程序中出现
我将JasperReports集成到我的springMVC网站中。 它在我的本地系统中运行良好,但当我将该网站上传到服务器时,报告正在生成,但它并没有像在我的本地系统中那样弹出
我正在使用iReport4.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();
# 1 楼答案
如果您使用Spring3,这可能会有所帮助
# 2 楼答案
首先,为什么要使用绝对路径。我认为应该使用相对路径(ServletContext.getRealPath())。 第二,这个代码是什么
当然,它不会显示在web浏览器中。要在浏览器中查看报告,请将pdf写入http servletresponse并相应地设置http标头