Error Can't see anything spring with jasper

问题描述 投票:0回答:0
@GetMapping(value = "/pdf/{id}", produces = MediaType.APPLICATION_PDF_VALUE)
public ResponseEntity<byte[]> downloadInvoice(@PathVariable Long id,Model model) throws JRException, IOException  {

    String reporPath="src/main/resources/templates/pages/user";
    
    JasperReport compileReport = JasperCompileManager
            .compileReport(new FileInputStream(reporPath + "/invoice.jrxml"));  
    
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("total", "7000");
    
    
    JasperPrint jasperPrint = JasperFillManager.fillReport(compileReport,parameters);
    
    
    
    byte data[] = JasperExportManager.exportReportToPdf(jasperPrint);

    

    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Disposition", "inline; filename=invoice.pdf");

    return ResponseEntity.ok().headers(headers).contentType(MediaType.APPLICATION_PDF).body(data);
    
    
}

这是我的控制器,我想预览报告但看不到任何东西 请帮助我,当用户点击按钮并显示 jasper 报告时,我想按 id 显示报告

spring thymeleaf jasper-reports
© www.soinside.com 2019 - 2024. All rights reserved.