我想在Struts 2.3.4中使用DynamicJasper 5.0.0。我使用下面的代碼來顯示PDF格式沒有爲名稱'success'映射的類型'dynamic-jasper'定義的結果類型
數據在動作類
try {
FastReportBuilder drb = new FastReportBuilder();
DynamicReport dr = drb.addColumn("Size", "size", String.class.getName(), 30).setTitle("Size List Report").setSubtitle("This report was generateed at" + new Date()).setUseFullPageWidth(true) //make colums to fill the page width
.setPrintBackgroundOnOddRows(true).build();
JRDataSource ds = new JRBeanCollectionDataSource(getSizeList());
JasperPrint jp = DynamicJasperHelper.generateJasperPrint(dr, new ClassicLayoutManager(), ds);
JasperViewer.viewReport(jp); //finally display the report report [/CODE]
} catch (Exception e) {
System.out.println("Exception");
}
return SUCCESS;
struts.xml的
<package name="expotpkg" extends="struts-default, json-default,jasperreports-default">
<result-types>
<result-type name="dynamic-jasper" class="ar.com.fdvs.dj.webwork.DJResult"/>
</result-types>
<action name="DownloadSizePdf" class="iland.work.SizesAction" method="fetchDJ">
<result name="success" type="dynamic-jasper">
<param name="dynamicReport">dr</param>
<param name="dataSource">sizeList</param>
<param name="documentName">Dynamic Report generated with struts 2</param>
<param name="parameters">params</param>
<param name="format">PDF</param>
<param name="layoutManager">classic</param>
</result>
</action>
</package>
雖然運行此我收到以下錯誤
There is no result type defined for type 'dynamic-jasper' mapped with name 'success'. Did you mean 'dynamicJasper'? - result - file:/E:/Project/cxn/cnx/build/web/WEB-INF/classes/struts.xml:571:58
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:653)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:387)
... 20 more
我已經包含以下jar文件
你還沒有定義'dynamic-jasper'結果。 –
@AleksandrM如何定義它 –