jasperreport报表打印

使用servlet打印jasperreport报表报错。
代码:
public class IreportPrintToPDFServlet extends HttpServlet{
private static final long serialVersionUID = 6085554729556239850L;
private static final String CONTENTTYPE = "application/octet-stream";
/**构造方法*/
public IreportPrintToPDFServlet(){
super();
}

/**Servlet关闭时执行方法*/
public void destroy(){
    super.destroy();
}

/**Servlet的doGet方法*/
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
    String fileName = "";
    String sql = "select id,dname,dcode from ct_su_departments where datalevel = 0 and status = 0 and rownum <=200";
    HashMap<String, Object> param = new HashMap<String, Object>();
    Connection conn = DataConnection.createConnection();//建立连接
    try {
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        response.setContentType(CONTENTTYPE);
        fileName = this.getServletContext().getRealPath("/ireport/report1.jrxml");//获取文件绝对路径
        JasperReport jrt = JasperCompileManager.compileReport(fileName);//编译报表格式 ,将jrxml格式文件编译为jasper格式文件
        JasperPrint jpt = JasperFillManager.fillReport(jrt, param, new JRResultSetDataSource(rs));//匹配数据源,生成JasperPrint
        response.setContentType("application/pdf");//设置输出文件类型
        response.setCharacterEncoding("UTF-8");//设置字节编码
        JRPdfExporter exporter = new JRPdfExporter();// 使用JRPdfExproter导出器导出pdf
        exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jpt);// 设置JasperPrintList
        exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, response.getOutputStream());// 设置导出流
        exporter.exportReport();// 开始导出
    } catch (Exception e) {
        System.out.println("Error:" + e.toString());
        e.printStackTrace();
    }finally{
        DataConnection.CloseConnect(conn);
        conn = null;
    }
}

/**Servlet的doPost方法*/
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
    this.doGet(request, response);
}

}

报错信息:
[14:06:27.644] java.lang.NoSuchFieldError: PRINTSCALING
[14:06:27.644] at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:534)
[14:06:27.644] at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:398)
[14:06:27.644] at dzjxkh.ireportPrint.IreportPrintToPDFServlet.doGet(IreportPrintToPDFServlet.java:53)
[14:06:27.644] at javax.servlet.http.HttpServlet.service(HttpServlet.java:114)
[14:06:27.644] at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
[14:06:27.644] at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
[14:06:27.644] at com.filter.SessionFilter.doFilter(SessionFilter.java:201)
[14:06:27.644] at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:76)
[14:06:27.644] at netsky.cabp.web.filter.LocaleFilter.doFilter(Unknown Source)
[14:06:27.644] at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:76)
[14:06:27.644] at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178)
[14:06:27.644] at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:241)
[14:06:27.644] at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
[14:06:27.644] at com.caucho.server.port.TcpConnection.run(TcpConnection.java:586)
[14:06:27.644] at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:690)
[14:06:27.644] at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:612)
[14:06:27.644] at java.lang.Thread.run(Thread.java:745)

有哪位大神遇到过,请赐教一下!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问