How can I pass an arbitrary object to jasper report as parameter?

后端 未结 2 758
遇见更好的自我
遇见更好的自我 2020-12-15 00:11

I would like to pass as a parameter to my .jrxml an arbitrary object of my domain, e.g a Person.

InputStream reportFile = MyPage.this.getClass().getResource         


        
2条回答
  •  感情败类
    2020-12-15 00:34

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

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

     
          
    

    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.

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

提交回复
热议问题