Our environment uses Struts 2-Spring-Hibernate + Jasper for reporting. The challenge is how to pass the connection to the JasperReports.
So here is the solution I came up with:
1. Make sure that the dataSource is declared in Spring.
1. Make sure that the dataSource is declared in Spring.
2. Add a DataSource variable to the Action. In this example I autowired the datasource; it can also be mapped declaratively.
3. Add a Connection variable in the Action and a getter. The connection will be set when the method that will return the Report is called.
4. In the struts.xml, provide the connection parameter name with the name of the connection variable in the action class.
1 comment:
very Useful......
Post a Comment