我用IReport制作的图形报表,在JSP中图片显示为X,显示不出来。
具体代码如下:
public void selectHtmlReport(List list,HttpServletResponse response,String url,Map map){
response.setContentType("text/html;charset=utf-8");
File reportFile = new File(url);
JasperReport jasperReport = null;
try {
jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
} catch (JRException e) {
e.printStackTrace();
}
JRBeanCollectionDataSource jrbean = new JRBeanCollectionDataSource(list);
JasperPrint jasperPrint = null;
try {
jasperPrint = JasperFillManager.fillReport(jasperReport,map,jrbean);
} catch (JRException e) {
e.printStackTrace();
}
JRHtmlExporter exporter = new JRHtmlExporter();
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
try {
exporter.exportReport();
} catch (JRException e) {
e.printStackTrace();
}
}
具体代码如下:
public void selectHtmlReport(List list,HttpServletResponse response,String url,Map map){
response.setContentType("text/html;charset=utf-8");
File reportFile = new File(url);
JasperReport jasperReport = null;
try {
jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
} catch (JRException e) {
e.printStackTrace();
}
JRBeanCollectionDataSource jrbean = new JRBeanCollectionDataSource(list);
JasperPrint jasperPrint = null;
try {
jasperPrint = JasperFillManager.fillReport(jasperReport,map,jrbean);
} catch (JRException e) {
e.printStackTrace();
}
JRHtmlExporter exporter = new JRHtmlExporter();
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
try {
exporter.exportReport();
} catch (JRException e) {
e.printStackTrace();
}
}
解决方案 »
- 现在有一个系统想做一个全文检索功能如何做
- java应用程序如何访问局域网内oracle数据库
- ssh配置问题
- 求jspsmartload下载中文名问题?解决即给分!
- 在myeclipse的环境下的JDBconnection的类,为什么连不上数据库,打开网页就出现错误直接走到system.out.println(“123456
- 有什么办法让用户浏览网页只用一个数据库连接?
- 高分求用javaBean实现的目录树及在JSP页面中的调用实例
- 如何解决java.lang.OutOfMemoryError错误
- jsp中是否有这个函数或方法
- 老总要我做setup,我该怎么办?
- 拥有enctype="multipart/form-data"的表单无法获取表单中除了type=file以外的其他参数不能被传递的解决方法
- 关于jsf项目中的editor,或者用过ck-jsf-editor的进来看看
图形报表 不成功。解决了不?QQ:782845859