【问题标题】:Spring Boot Jasper Report Blank PDFSpring Boot Jasper 报告空白 PDF
【发布时间】:2017-03-31 02:35:13
【问题描述】:

我有一个网络应用程序。我使用 Spring Boot 1.3.3、AngularJS 和 Jasper 5.6.0。当我尝试下载 jasper 报告时,我得到空白的 PDF 页面。我的代码是:

String jasperAdi = "yillikPlan.jasper";
StringBuffer pathMain = new StringBuffer();
pathMain.append(this.getClass().getResource("/static/jasper").getPath());
String jasperFileName = pathMain.toString() + File.separator + jasperAdi;
File jasperFile = new File(jasperFileName);
JasperReport report = (JasperReport) JRLoader.loadObject(jasperFile);
JasperPrint jasperPrint = JasperFillManager.fillReport(report, param, new JRBeanCollectionDataSource(ckModelList));
if (jasperPrint != null) {
    byte[] pdfReport = JasperExportManager.exportReportToPdf(jasperPrint);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.parseMediaType("application/pdf"));
    headers.setContentDispositionFormData("yillikPlan.pdf", "yillikPlan.pdf");
    ResponseEntity<byte[]> respon = new ResponseEntity<byte[]>(pdfReport, headers, HttpStatus.OK);
    return respon;

}

我的 jasper 文件位置是 /static/jasper。 ckModelList 是一个 java.util.List。 param 是我推送报告参数的 Hashmap。

我如何解决这个问题。

【问题讨论】:

  • 你尝试调试了吗?数据源好吗?
  • 是的,我尝试调试。我的数据源没问题。 @AlexK
  • 我面临同样的问题。你解决了吗?
  • @tranceholic 不,我没有解决这个问题。

标签: java spring spring-boot jasper-reports


【解决方案1】:

当我尝试在我的 Spring Boot 应用程序中开始使用 jasper 时,我遇到了同样的问题,但我的 java 代码没有任何问题,它只是报告的属性“当没有数据类型时”。我只是在测试,因此我没有任何数据,只有一个标签,需要几个小时才能实现。

如果您在理解我的“改进”英语时有任何问题,请告诉我,我会尽力解释得更好。

Report Properties Image

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多