Java 如何在jasper报表中调用实体方法?
我不能在jasper报告中调用SpringMVC实体方法。这是我想在jasper report中调用的方法Java 如何在jasper报表中调用实体方法?,java,spring,Java,Spring,我不能在jasper报告中调用SpringMVC实体方法。这是我想在jasper report中调用的方法 public BigDecimal getOutstanding(){ BigDecimal currentBalance = this.getCurrentBalance() != null ? this.getCurrentBalance() : new BigDecimal(0); BigDecimal payableAmount = this.get
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.jrvalidateException:报表设计无效:
1.java.lang.ClassNotFoundException:com.rightbrainsolution.titas.domesticbilling.entities.Customer您不能调用自定义类的
方法。如果导入了类的编译版本,则可以调用类的方法,然后可以执行以下操作
正如我所看到的,您有一个getter方法get杰出
,您可以简单地将杰出
用作一个字段(尽管杰出
不是一个真正的字段),如
错误告诉您:当您尝试生成报告时,您的客户
类不在jasper的类路径上。调用属性访问器并没有问题(您没有走那么远)
<textFieldExpression><![CDATA[$F{outstanding}]]></textFieldExpression>