没有为映射名称为“success”的类型“dynamic-jasper”定义结果类型

问题描述 投票:0回答:1

我正在尝试将 DynamicJasper 5.0.0 与 Struts 2.3.4 一起使用。我使用以下代码以 PDF 格式显示数据:

动作课中:

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 文件:

enter image description here

java struts2 jasper-reports dynamic-jasper
1个回答
0
投票

将此配置添加到您的包中

<result-types>
    <result-type name="dynamicJasper" class="ar.com.fdvs.dj.webwork.DJResult"/>
</result-types>

<action name="DownloadSizePdf" class="iland.work.SizesAction" method="fetchDJ">
    <result name="success" type="dynamicJasper">
        <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>

ActionSupport
类位于包名称
com.opensymphony.xwork2
下。该错误是由于您与 Struts2 一起使用的插件配置与您使用的 Struts 版本不兼容而发生的。

© www.soinside.com 2019 - 2024. All rights reserved.