【发布时间】:2019-05-02 01:13:34
【问题描述】:
所以,我已经制作了报告,但问题是我正在使用 GetMapping 进行显示,它单独在另一个页面上打开,但我需要它在 div、表格、卡片或甚至是模态的。它只是不能改变上一页。
我不知道如何在不重定向页面的情况下打开它。任何建议表示赞赏
控制器上的方法
@GetMapping("/seguro")
public void export(HttpServletResponse response) throws IOException, JRException, SQLException {
response.setContentType("text/html");
JasperPrint jasperPrint = null;
jasperPrint = seguroReportService.generatePromissoria(1L);
HtmlExporter htmlExporter = new HtmlExporter(DefaultJasperReportsContext.getInstance());
htmlExporter.setExporterInput(new SimpleExporterInput(jasperPrint));
htmlExporter.setExporterOutput(new SimpleHtmlExporterOutput(response.getWriter()));
htmlExporter.exportReport();
}
获取报告文件的方法
public JasperPrint generatePromissoria(Long id) throws SQLException, JRException, IOException {
Connection conn = jdbcTemplate.getDataSource().getConnection();
String path = resourceLoader.getResource("classpath:/reports/SeguroReport.jrxml").getURI().getPath();
JasperReport jasperReport = JasperCompileManager.compileReport(path);
// Parameters for report
Map<String, Object> parameters = new HashMap<>();
parameters.put("titulo", "Relatório de Seguros");
parameters.put("ID", id);
JasperPrint print = JasperFillManager.fillReport(jasperReport, parameters, conn);
return print;
}
【问题讨论】:
-
你在web端使用什么? jQuery、Angular、试图放入 iFrame 等?基于此,有不同的方法。
-
@kendavidson 我是新手,不知道能否回答您的问题,但我使用的是弹簧和百里香叶。我去看看iframe,看起来很有趣。
-
确保写下你为解决它所做的工作。
标签: java html spring jasper-reports thymeleaf