gpt4 book ai didi

image - JasperReports 中当其值为 NULL 或空时隐藏图像

转载 作者:行者123 更新时间:2023-12-02 11:04:13 24 4
gpt4 key购买 nike

我使用的是JasperReports 6.2.2版本。如果值为 null 或为空,我想隐藏图像。

下面的代码我在 jrxml 中使用来隐藏图像,但这对我不起作用。

<image>
<reportElement x="33" y="0" width="88" height="45" uuid="182b40f8-b18e-417c-b9f4-096199533567">
<printWhenExpression><![CDATA[($F{urlImage}!=null ? $F{urlImage} : "")]]></printWhenExpression>
</reportElement>
</image>

$F{urlImage}是String类型

报错

ERROR [btpool0-2] (JRFillSubreport.java:866) - Fill 1: exception
[java] java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
[java] at net.sf.jasperreports.engine.fill.JRFillElement.evaluatePrintWhenExpression(JRFillElement.java:806)
[java] at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:471)
[java] at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
[java] at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:159)
[java] at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
[java] at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2022)
[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748)
[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
[java] java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
[java] at net.sf.jasperreports.engine.fill.JRFillElement.evaluatePrintWhenExpression(JRFillElement.java:806)
[java] at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:471)
[java] at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
[java] at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:159)
[java] at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
[java] at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2022)
[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748)
[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
[java] at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
[java] at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
[java] at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:736)
[java] at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
[java] at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)
[java] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[java] at java.lang.Thread.run(Unknown Source)
[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
[java] at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
[java] at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
[java] at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:736)
[java] at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
[java] at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)
[java] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[java] at java.lang.Thread.run(Unknown Source)

如果图像的值为 null 或空,如何隐藏图像。 urlImage 字段包含图像的 url。例如:“[http://use.example.com/pop.png][1]”。

最佳答案

您可以在 Jaspersoft Studio 中执行此操作:

enter image description here

这会在 jrxml 中创建以下行:

<image isUsingCache="true" onErrorType="Blank">

关于image - JasperReports 中当其值为 NULL 或空时隐藏图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42973754/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com