Applet无法识别Tomcat服务上的相对路径?

时间:2014-07-21 07:04:01

标签: java tomcat applet jasper-reports

我的应用中出现了一些错误。该应用程序正在使用applet访问本地文件系统。 例如,转换文件。

首先:使用相对路径。 我可以将项目文件夹放在我需要的地方,并且应用程序仍能正常工作。但是,当我把它放在tomcat服务器目录上时,它找不到文件'路径。

  1. 使用浏览器运行:file:/// C:/report-param/index.html,ok
  2. 使用浏览器运行:localhost:8080 / report-param / index.html,错误
  3. 第二名:使用绝对路径。 该应用程序在浏览器和tomcat服务器上都运行良好。

    1. 使用浏览器运行:file:/// C:/report-param/index.html,ok
    2. 使用浏览器运行:localhost:8080 / report-param / index.html,ok
    3. 以下是我的示例代码:

      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);
      

      这里有什么问题?有什么想法吗?

      如何解决上述错误?请帮忙......

      注意:如果你不明白,请随时问我......

0 个答案:

没有答案