我正在为报告引擎使用JSP和JasperReports开发Java Web应用程序。而且我正在使用AWS ELB作为应用程序服务器。
我不确定.jasper文件应放在哪里以及如何访问。
我的项目结构:
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9kZHpWei5wbmcifQ==” alt =“我的项目文件看起来如何”>“ >>
我尝试过:
String jasperPath = "\\report\\TestPengguna.jasper";
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperPath, new HashMap(), JConnectionUtil.con);
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
String jasperPath = "\\TestPengguna2.jasper";
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperPath, new HashMap(), JConnectionUtil.con);
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
String jasperPath = "\\report\\TestPengguna.jasper";
ClassLoader cl = this.getClass().getClassLoader();
JasperPrint jasperPrint = JasperFillManager.fillReport(cl.getResourceAsStream(jasperPath), new HashMap(), JConnectionUtil.con);
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
我正在为报告引擎使用JSP和JasperReports开发Java Web应用程序。而且我正在使用AWS ELB作为应用程序服务器。我不确定.jasper文件应该放在哪里以及如何放置...
jasper文件的全部要点是,它们是与您的项目分开编译的,可以在出现格式问题或样式干预的情况下进行编辑哈哈。我将编译的jasper文件保存在运行该项目的服务器的opt文件夹中,并像opt/someFolder/report/TestPengguna.jasper
一样对其进行访问。我使用jaspersoft studio应用程序通过this
感谢您的回答。就我而言,在开发计算机中运行.jasper文件时,我可以成功访问它。