且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将任意对象作为参数传递给jasper报告?

更新时间:2023-11-07 21:02:40

是的,您可以传递任何Java对象,但是您应该确保在JRXML中导入该对象。

Yes, you can pass any Java object, but you should make sure to import that object in the JRXML.

jasperReport标签。您可以使用标签 import ,例如:

Inside the jasperReport tag. You can use the tag import, like:

 <jasperReport...>
      <import value="org.justfortest.Person">

但是,您可以使用 JRBeanCollectionDataSource 并填充带有对象列表的报告,无需在params映射中存储任意对象。

However, you can use JRBeanCollectionDataSource and populate the report with a list of your object, without needing to store arbitrary objects in the params map.

查看本教程以获取有关 Jasper Reports Bean Collection数据源

Check this tutorial for more info on Jasper Reports Bean Collection Data Source