问题描述
<%@pagecontentType="application/pdf;charset=utf-8"%><%@pageimport="net.sf.jasperreports.engine.*"%><%@pageimport="java.util.*"%><%@pageimport="java.io.*"%><%@pageimport="java.sql.*"%><%//报表编译之后生成的.jasper文件的存放位置FilereportFile=newFile(this.getServletContext().getRealPath("/ireport/myeclips_report.jasper"));Stringurl="jdbc:microsoft:sqlserver://localhost;DatabaseName=m18wmstest";Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");Mapparameters=newHashMap();//"SQLSTR"是报表中定义的一个参数名称,其类型为String型parameters.put("test","selecttop50B.SKUASSKU,B.FMQTYASFMQTY,A.MDOCNOASMDOCNO,B.FMLOCATIONASFMLOCATIONFROMDOC_Movement_HeaderASA,DOC_Movement_DetailsASBWHEREA.MDOCNO=B.MDOCNO");Connectionconn=DriverManager.getConnection(url,"sa","sql");byte[]bytes=JasperRunManager.runReportToPdf(reportFile.getPath(),parameters,conn);response.setContentType("application/pdf");response.setContentLength(bytes.length);out.clear();out=pageContext.pushBody();ServletOutputStreamoutStream=response.getOutputStream();outStream.write(bytes,0,bytes.length);outStream.flush();outStream.close();%>各位大侠,小弟写完了,运行没有报错,pdf也出来了就是没有值,为空白。求解脱!!!