。jasper文件应该放在哪里以及如何访问它?

问题描述 投票:0回答:2

我正在为报告引擎使用JSP和JasperReports开发Java Web应用程序。而且我正在使用AWS ELB作为应用程序服务器。

我不确定.jasper文件应放在哪里以及如何访问。

我的项目结构:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9kZHpWei5wbmcifQ==” alt =“我的项目文件看起来如何”>“ >>

我尝试过:

  1. 将文件夹放入Web文件夹,然后将.jasper放入其中。我使用以下代码访问它
  2. String jasperPath = "\\report\\TestPengguna.jasper";
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperPath, new HashMap(), JConnectionUtil.con);
    JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
    
  1. 将.jasper放在Web文件夹中,然后像这样访问它
  2. String jasperPath = "\\TestPengguna2.jasper";
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperPath, new HashMap(), JConnectionUtil.con);
    JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
    
  1. 使用此代码访问
  2. 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文件应该放在哪里以及如何放置...

java jasper-reports amazon-elastic-beanstalk war
2个回答
0
投票

jasper文件的全部要点是,它们是与您的项目分开编译的,可以在出现格式问题或样式干预的情况下进行编辑哈哈。我将编译的jasper文件保存在运行该项目的服务器的opt文件夹中,并像opt/someFolder/report/TestPengguna.jasper一样对其进行访问。我使用jaspersoft studio应用程序通过this


0
投票

感谢您的回答。就我而言,在开发计算机中运行.jasper文件时,我可以成功访问它。

© www.soinside.com 2019 - 2024. All rights reserved.