JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
Map parameters = new HashMap();
parameters.put("path",realPath+"//");
parameters.put("images_paths",context.getRealPath("/reports/images")+"//");
parameters.put("sub_path",context.getRealPath("/reports")+"//");
.......
conn = jdbcDao.getJDBCConnection();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
JRHtmlExporter exporter = new JRHtmlExporter();
request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "./reports/images/");
exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,header.toString());
exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML,"<HR>");
exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,context.getRealPath("/reports/images")+"//");
// 设置允许输出图片
exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR,Boolean.TRUE);
exporter.setParameter(JRHtmlExporterParameter.SIZE_UNIT,"pt");
exporter.exportReport();