1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > jasperreport转成html JasperReport chart导出HTML不能显示chart图

jasperreport转成html JasperReport chart导出HTML不能显示chart图

时间:2022-07-03 09:40:07

相关推荐

jasperreport转成html JasperReport chart导出HTML不能显示chart图

使用JaspeReport chart生成PIE图,导出成Pdf、Excel文件时PIE图都正常,但是若导出成HTML并直接显示(意思是:不是先导出成html文件,然后在打开这个html文件,而是让浏览器直接解析JasperReport生成的HTML)就会出现问题。代码如下:

Java code:

outStream = response.getOutputStream();

/*

*部分代码省略

*/

export = new JRHtmlExporter();

extension = ".html";

contentType = "text/html";

//String imageURI = request.getContextPath()+"/reportfiles/images/";

String imageURI = "c:/images/";

export.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.TRUE);

export.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);

export.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME, imageURI);

export.setParameter(JRHtmlExporterParameter.IMAGES_URI, imageURI);

export.setParameter(JRExporterParameter.JASPER_PRINT, jp);

export.setParameter(JRExporterParameter.OUTPUT_STREAM, outStream);

response.setContentType(contentType);

export.exportReport();

如果使用 String imageURI = request.getContextPath()+"/reportfiles/images/";

那么图片根本不会显示。

如果按上面给的代码,第一次执行时会在 c:/images/ 下生成一个图片文件img_0_0_1,但是页面中还是显示红叉(找不到该文件),查看红叉的路径,发现其地址已是file://

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。