IReport
Problems in Master/Slave reports [Reproduced]I recently encountered the following problems when I used ireport and jasperreport for web reports:
In ireport, after the Master/Slave report is created, the ireport can be compiled, run, and displayed properly. However, the following error occurs when you add the report to javaweb:
Cocould not load object from location: subunitlab. Jasper, that is, the template (Jasper) file of the subreport cannot be found in the main report.
Main reasons:
The master report cannot find the Jasper file of the subreport (in-depth analysis)
Solution:
In the main report, set the variable subreport_dir (new if it does not exist) to represent the true path of the subreport template file. Set the subreport expression value of the subreport attribute: $ P {subreport_dir} + "subreportname. jasper ", through the program to dynamically set subreport_dir, so that the winner report can obtain the true path of the subreport template file.
The procedure is as follows:
1. Set the main report variable: subreport_dir
Set Default Value à modify à select subreport_dir variable name à parameters à Veiw expression value :"";
2. Modify subreport attributes
Right-click the subreport in the main report, select the subreport (other) option, and set the subreport expression value to $ P {subreport_dir} + "subreportname. Jasper"
3. dynamically obtain the true path of the subreport in action and set it to the value of subreport_dir: Param. setparameters ("subreport_dir", request. getrealpath ("/reports/") + "/");
For multiple subreports, the procedure is similar. You only need to set the subreport attributes (premise: All subreports are stored in the same path). If they are stored in different paths, you must create multiple variables in the main report that represent the sub-Report path, correspond to each sub-Report one by one, and set the true path one by one through the program.