Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 部署JasperReport时+;web项目到Tomcat7,它无法显示导出的Html_Java_Linux_Tomcat_Jasper Reports - Fatal编程技术网

Java 部署JasperReport时+;web项目到Tomcat7,它无法显示导出的Html

Java 部署JasperReport时+;web项目到Tomcat7,它无法显示导出的Html,java,linux,tomcat,jasper-reports,Java,Linux,Tomcat,Jasper Reports,我可以在MyEclipse Tomcat中正确运行该项目,您可以从image1中看到它 饼图: 但后来我将.war文件保存到Tomcat,我什么也没有得到,如图2所示 [失败的节目][2] 下面是我关于exort的代码 File reportFile = new File(this.getServletConfig().getServletContext().getRealPath("/report2.jasper")); List<SatisfPieData> satisfPie

我可以在MyEclipse Tomcat中正确运行该项目,您可以从image1中看到它

饼图:

但后来我将.war文件保存到Tomcat,我什么也没有得到,如图2所示

[失败的节目][2]

下面是我关于exort的代码

File reportFile = new File(this.getServletConfig().getServletContext().getRealPath("/report2.jasper"));
List<SatisfPieData> satisfPieDataList = satifyDao.querySatisfPieData(sql);
JRDataSource dataSource = new JRBeanCollectionDataSource(satisfPieDataList);        
Map<String, Object> parameters = new HashMap<String, Object>();
try
    {
        PrintWriter out = response.getWriter();
        try
        {
            //response.setContentType("text/html;charset=UTF-8");
            response.setContentType("text/html");

            JasperReport jasperReport = (JasperReport) JRLoader.loadObjectFromFile(reportFile.getPath());

            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,dataSource);

            HtmlExporter exporter = new HtmlExporter();
            request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);

            exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
            SimpleHtmlExporterOutput output = new SimpleHtmlExporterOutput(out);
            output.setImageHandler(new WebHtmlResourceHandler("image?image={0}"));
            exporter.setExporterOutput(output);

            exporter.exportReport();
        }
        catch(JRException jre)
        {
            jre.printStackTrace();
        }
        finally
        {
            if(out!= null)
            {
                try
                {
                    out.close();
                }
                catch(Exception e)
                {

                }
            }
        }
    }
    catch(IOException ioe)
    {
        ioe.printStackTrace();
    }
好像有个错误,但我没听懂。函数似乎没有结束或正在被赋予

jasperPrint功能似乎并未结束:


有人知道错误的原因吗?我将不胜感激

你的问题不清楚。应用程序是否冻结了此方法(JasperFillManager.fillReport)?是的,诸如“JRBeanCollectionDataSource”、“JRLoader.loadObjectFromFile”等函数可以成功运行。但该方法(JasperFillManager.fillReport)似乎已冻结。不管我等了多久,程序都无法运行下一个代码“System.out.println”(“jasperPrint end”)”。顺便说一下,数据源只有3行。整个项目可以在内部MyEclipse Tomcat中成功运行,但在外部Tomcat中运行失败。这让我很困惑。谢谢。@Alex K
JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport,parameters,dataSource)