JasperReports:无法找到子报告 [英] JasperReports: Can't locate subreport

查看:126
本文介绍了JasperReports:无法找到子报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我发疯了。最后一小时我试图弄清楚为什么我的报告在我添加子报告后才停止工作..
我已经检查并尝试了所有类似的问题在其中 here 这里
没有成功..子报告肯定在同一个目录中..
定义如下:

It's drives me crazy.. Last hour I am trying to figure out why my report stopped to worked right after I added a subreport to it.. I already checked and tried all similar issues here, here and here. Without success.. Subreport is in the same directory for sure.. The definition looks like:

<subreport isUsingCache="false">
                <reportElement uuid="db816b3c-a13d-440f-a6a2-f899762e61e4" x="0" y="89" width="555" height="100"/>
                <subreportParameter name="footerAddress">
                    <subreportParameterExpression><![CDATA[$P{footerAddress}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="footerManager">
                    <subreportParameterExpression><![CDATA[$P{footerManager}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="footerContact">
                    <subreportParameterExpression><![CDATA[$P{footerContact}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="footerBank">
                    <subreportParameterExpression><![CDATA[$P{footerBank}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{SUBREPORT_DIR}]]></subreportExpression>
            </subreport>

其中$ P {SUBREPORT_DIR}是/ valid / path / sub。 report.jasper

Where $P{SUBREPORT_DIR} is "/valid/path/sub.report.jasper"

我仍然收到错误:在/ valid / path / sub找不到资源。 report.jasper

为什么??

推荐答案

在第一封邮件中,作者说:

In first message author says:

$ P {SUBREPORT_DIR} /valid/path/sub.report.jasper

Where $P{SUBREPORT_DIR} is "/valid/path/sub.report.jasper"

$ P {SUBREPORT_DIR} 目录,但不是文件名。这是第一个错误。

$P{SUBREPORT_DIR} is a directory, but not a filename. It is the first error.

第二个错误:有时jasper无法找到子报告,即使路径是正确的。

The second: sometimes jasper can't find subreport, even the path is correct.

解决此问题的方法:


  1. 传递 $ P {SUBREPORT_DIR} 进入报告(在这种情况下: / valid / path / ),将此参数放入 HashMap< ; String,Object> - 标准方式将参数传递给jasper。

  2. 传递 $ P {SUBREPORT_DIR} 从主报告进入子报告作为参数: $ P {SUBREPORT_DIR} 主报告 - > 子报表的$ P {SUBREPORT_DIR} (这种方式在存在子报表时使用,从子报表调用)

  3. 在主报表集表达式中,子报表为 $ P {SUBREPORT_DIR} + sub.report.jasper

  1. Pass $P{SUBREPORT_DIR} into main report (In this case: "/valid/path/"), put this parameter into a HashMap<String, Object> - standard way pass parameters into jasper.
  2. Pass $P{SUBREPORT_DIR} from main report into subreport as parameter: $P{SUBREPORT_DIR} main report -> $P{SUBREPORT_DIR} of subreport (this way used when exist subsubreport, which calling from subreport)
  3. In main report set expression to subreport as $P{SUBREPORT_DIR} + "sub.report.jasper"

这篇关于JasperReports:无法找到子报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆