<%
String fileName = JasperCompileManager.compileReportToFile("RTAReport.jrxml");
File reportFile = new File(fileName); JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath()); Map parameters = new HashMap();
/*parameters.put("Reporttitle", "Address Report");
parameters.put("BaseDir", reportFile.getParentFile());*/ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=HNDB_DATA","sa","");
JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport,parameters,conn); JRHtmlExporter exporter = new JRHtmlExporter();
response.setContentType("text/html");
Map imagesMap = new HashMap();
session.setAttribute("IMAGES_MAP", imagesMap);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image.jsp?image=");
exporter.exportReport();
%>
请问为什么一直无法输出html文档??
能讲讲html输出的原理吗??
String fileName = JasperCompileManager.compileReportToFile("RTAReport.jrxml");
File reportFile = new File(fileName); JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath()); Map parameters = new HashMap();
/*parameters.put("Reporttitle", "Address Report");
parameters.put("BaseDir", reportFile.getParentFile());*/ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=HNDB_DATA","sa","");
JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport,parameters,conn); JRHtmlExporter exporter = new JRHtmlExporter();
response.setContentType("text/html");
Map imagesMap = new HashMap();
session.setAttribute("IMAGES_MAP", imagesMap);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image.jsp?image=");
exporter.exportReport();
%>
请问为什么一直无法输出html文档??
能讲讲html输出的原理吗??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货