读书人

Struts2整合JasperReport预览HTML格式

发布时间: 2012-12-18 12:43:41 作者: rapoo

Struts2整合JasperReport预览HTML格式不显示图片问题解决方案(转)

?关于怎么整合网上到处都是例子、apache也有比较详细的例子说明,我是参考这篇文章的http://www.blogjava.net/sterning/archive/2008/01/02/172317.html我使用他的源码HTML预览时还是不能正常显示,images/px(网上的一种解决方案)都有还是不能正常显示,无奈之下只有查看源代码了。
Struts2对通过JasperReportsResult.java类的doExecute方法对JasperReport进行了简单的整合,这个方法对JasperReport的API简单的包装(车轮理论^_^)

Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)JasperReport?jasperReport?=?(JasperReport)?JRLoader.loadObject(systemId);
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????????jasperPrint?=?JasperFillManager.fillReport(jasperReport,?parameters,?stackDataSource);其中systemId是这样来的Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)String?systemId?=?servletContext.getRealPath(finalLocation);也就是导入的是Jasper文件的绝对路径,Struts2直接使用的jasper文件(编译报表很耗时!不推荐使用jrxml文件)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)<param?name="location">/jasper/notification.jasper</param>至于Action的代码就不必写的那么复杂了Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)package?org.bulktree.jasper;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)import?net.sf.jasperreports.engine.JRDataSource;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)import?net.sf.jasperreports.engine.JREmptyDataSource;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)import?net.sf.jasperreports.engine.JasperCompileManager;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)import?org.apache.struts2.ServletActionContext;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)import?com.opensymphony.xwork2.ActionSupport;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)/**
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)?*?
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)?*?@author?bulktree?Email:?laoshulin@gmail.com?@?Nov?26,?2008
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)?*/
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)public?class?JasperAction?extends?ActionSupport?{
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????private?JRDataSource?reportDataSource;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????@Override
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????public?String?execute()?throws?Exception?{
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????//定义一个自定义的数据源
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????reportDataSource?=?new?JREmptyDataSource();
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????/*编译很耗时,Ireport可以编译jrxml文件可以减少程序运行的压力
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)?????????*?下面一段代码可以不写直接使用Ireport编译好的jasper文件
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)?????????*?
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)?????????*/
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)/*????????ServletActionContext.getRequest().setAttribute("name",?"LAOSHULIN");
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????String?path?=?ServletActionContext.getServletContext().getRealPath("/jasper");
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????System.out.println(path);
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????String?sourceFileName?=?path?+?"\\"?+?"CarInstance.jrxml";
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????String?destFileName?=?path?+?"\\"?+?"CarInstance.jasper";
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????JasperCompileManager.compileReportToFile(sourceFileName,?destFileName);*/
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????return?SUCCESS;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????}
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????public?JRDataSource?getReportDataSource()?{
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????return?reportDataSource;
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????}
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)}
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)被注释的代码只是指定jrxml文件和jasper文件的路径及编译过程,现实中不建议使用,关于jasperReport的各种强大功能本人会在项目结束后进行整理发布。
????继续吧!采用HTML格式预览时,莫名的出现一些图片的xx,但是我们并没有使用图片啊,关于这个为什么网上的资料很详细本人只是解读一下Struts2这个插件的源码最终解决图片显示问题Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)protected?String?imageServletUrl?=?"\images\";
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)?exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP,?imagesMap);
Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)????????????????exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,?request.getContextPath()?+?imageServletUrl);现在明白为什么要新建一个images目录复制象素图片了吧!
对于HTML预览时右击查看源代码出现的是相对路径,但是大多数情况下根据生成的路径不能指定到px图片,不知道是不是这个插件包本身的问题还是其它的原因,总之先做出效果来、修改上句换成绝对路径吧!Struts2整合JasperReport预览HTML格式不显示图片有关问题解决方案(转)exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,?servletContext.getRealPath(File.separator)?+?imageServletUrl);这个图片xx问题自然就会解决了。?
?? ? ??

读书人网 >CSS

热点推荐