SUBREPORT_DIR
サブレポートへのパスを渡すのに問題があります。レポートは実際には同じフォルダーにありますが、JAR ファイル内にあります。私はこのようなことを試しました(不正確かもしれません):
parameterList = new HashMap<String, Object>();
URL mainReport = this.getClass().getResource("mainReport.jasper");
String mainReportPath = mainReport.getPath();
String subreportDir = mainReportPath.substring(0, mainReportPath.lastIndexOf("/")+1);
parameterList.put("SUBREPORT_DIR", subreportDir);
このパスは JAR ファイル内を指していますが、net.sf.jasperreports.engine.JRException: Resource not found at : ...
レポート生成時に取得します。どうすればこれを機能させることができますか?
編集:
なしでサブレポートを定義しようとしましたSUBREPORT_DIR
が、うまくいきませんでした:
<subreport>
<reportElement x="0" y="32" width="475" height="17"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{current})]]></dataSourceExpression>
<subreportExpression><![CDATA["mysubreport.jrxml"]]></subreportExpression>
</subreport>