【问题标题】:How to call entity method in jasper report?如何在碧玉报告中调用实体方法?
【发布时间】:2015-12-24 12:58:09
【问题描述】:

我无法将 spring mvc 实体方法调用到 jasper 报告中。这是我想在 jasper 报告中调用的方法。

public BigDecimal getOutstanding(){
        BigDecimal currentBalance = this.getCurrentBalance() != null ? this.getCurrentBalance() : new BigDecimal(0);
        BigDecimal payableAmount = this.getPayableAmount() != null ? this.getPayableAmount() : new BigDecimal(0);
        return payableAmount.subtract(currentBalance);
    }

我尝试了以下方法:

 <field name="customer" class="com.rightbrainsolution.titas.domesticbilling.entities.Customer"/>

<textField>
                <reportElement x="810" y="-15" width="210" height="14" uuid="91aaf617-bd64-4406-a74e-9c9eee52db56"/>
                <textFieldExpression><![CDATA[$F{customer}.getOutstanding()]]></textFieldExpression>
</textField>

但不工作说:

[错误] 无法编译优秀的.jrxml net.sf.jasperreports.engine.design.JRValidationException:报告设计无效: 1. java.lang.ClassNotFoundException: com.rightbrainsolution.titas.domesticbilling.entities.Customer

【问题讨论】:

  • 错误告诉您:当您尝试生成报告时,您的 Customer 类不在 jasper 的类路径中。调用属性访问器不是问题(你没有那么远)。
  • 将客户添加到您的 jasper 报告的类路径

标签: java spring


【解决方案1】:

您不能调用自定义类的method。如果您导入了类的编译版本,则可以调用类的方法,然后您可以关注the post

正如我所见,你有一个 getter 方法 getOutstanding 你可以简单地使用 outstanding 作为一个字段(虽然 outstanding 不是一个真正的字段)像

<textFieldExpression><![CDATA[$F{outstanding}]]></textFieldExpression>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多