jasperreport+ireport做报表处理logon(处理图片显示的问题),多谢大家帮助?急!!!!!!!!!!!!!!!!

888888888888 2010-11-03 10:27:31
我为用ireport做报表要把公司的logon加在报表里,我图片加在报表里用ireport(html和其他的方式)预览能都能看到图片,但是.jasper加到jsp页面上不显示图片了,问题是当我保存为PDF和world能看到logon,就在jsp里看不到图片。

设置图片是这样做的,我在ireport里设置了一个参数$P{mages}参数名为mages,参数的类型是数据流类型,在报表上放了一个图片框,图片框的路径不是得到图片的路径而是这个参数$P{mages}。是在jsp页面为这个个参数传入数据留,
String imageRead = request.getRealPath( "WEB-INF/logon.jpg ");//获得图片路径File imageFile = new File(imageRead);
InputStream imageIn = new FileInputStream(imageFile);//图片一个数据流
parameters.put( "logo ",imageIn);//获得为图片设置的参数,把图片传给这个参数

这样为图片参数传值的,整个程序不报错,只是在jsp里看不到图片的效果,保存为其他的格式能看见这个图片。在jsp里右击不显示的图片属性看到的路径是:http://localhost:8083/servlets/imagesdir=img_0_0_1

十万火急,大家帮我看看吧。
...全文
243 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zaj_2009 2010-11-19
  • 打赏
  • 举报
回复
同样遇到这个问题,不知道怎么解
xiaobai7727 2010-11-09
  • 打赏
  • 举报
回复
JRHtmlExporter exporter = new JRHtmlExporter();
888888888888 2010-11-03
  • 打赏
  • 举报
回复
我是这样做的。

//生成html
JRHtmlExporter exporter = new JRHtmlExporter();

ByteArrayOutputStream oStream = new ByteArrayOutputStream();
JasperPrint jasperPrint = JasperFillManager.fillReport(rpt.getPath(), map, con);
exporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRHtmlExporterParameter.CHARACTER_ENCODING, "utf-8");
exporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, oStream);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath()+"/servlets/image?image=");
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);

exporter.exportReport();//导出

exporter.exportReport();
byte[] bytes = oStream.toByteArray();
response.setContentType("text/html");
response.setContentLength(bytes.length);
response.setCharacterEncoding("utf-8");
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
con.close();
out.clear();
out = pageContext.pushBody();
gotohbu 2010-11-03
  • 打赏
  • 举报
回复
参数传递到xxx.jasper之后,你是怎样处理的,把那段代码拿出来看看???
(你应该在ireport那里做处理的)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧