我的应用中出现了一些错误。该应用程序正在使用applet访问本地文件系统。 例如,转换文件。
首先:使用相对路径。 我可以将项目文件夹放在我需要的地方,并且应用程序仍能正常工作。但是,当我把它放在tomcat服务器目录上时,它找不到文件'路径。
第二名:使用绝对路径。 该应用程序在浏览器和tomcat服务器上都运行良好。
以下是我的示例代码:
File jrxmlPath = new File("reports//people-report-withparam-multi.jrxml");
File pdfPath = new File("reports//people-report-withparam-multi.pdf");
String sourceJrxml = jrxmlPath.getPath();
String destPdf = pdfPath.getPath();
JasperReport jasperReport = JasperCompileManager.compileReport(sourceJrxml);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, paramMap,
getPostgreSQLDataSource(driverUrl, username, password));
JasperExportManager.exportReportToPdfFile(jasperPrint,destPdf);
这里有什么问题?有什么想法吗?
如何解决上述错误?请帮忙......
注意:如果你不明白,请随时问我......