Struts Action 中的多个入口点(迁移 Struts 2.2.3 -> 2.3.1)

2022-01-16 00:00:00 java jsp struts2 dmi

我在 struts.xml 中有一个动作:

I have an action in struts.xml:

<action name="reprint" class="reprintAction">
        <result name="success" type="redirectAction">
            <param name="actionName">reprint</param>
            <param name="namespace">/x</param>
            <param name="errorFlag">${errorFlag}</param>
            <param name="message">${message}</param>
        </result>
        <result name="view">/jsp/reprintOverview.jsp</result>
</action>

JSP:

<s:form action="reprint">
    <s:select name="selectedPdfPrinter" list="shopPdfPrinterList" listKey="deviceId" listValue="deviceId" theme="simple"/>
    <s:submit value="Print" theme="simple" method="shopPdfReprint"/>
</s:form>

有几个表单元素,都绑定到一个动作.每个表单都有一个单独的提交按钮,带有不同的 method(例如 shopPdfReprint").每个 method 都映射到相应类中的方法.

with several form elements, all bound to one action. Each form has an individual submit-button with a distinct method (e.g. "shopPdfReprint"). Each method is mapped on to a method in the corresponding class.

使用 Struts 2.2.3 一切正常.但是在迁移到 2.3.1 之后,方法映射不起作用.而不是调用相应的方法(例如shopPdfReprint"),只调用类的execute()方法.

Everything is working fine with Struts 2.2.3. But after Migration to 2.3.1 the method-mapping is not working. Instead calling the corresponding method (e.g. "shopPdfReprint"), only the execute() method of the class is invoked.

我查看了Docs,但不幸的是没有找到任何线索,如何适应2.3.1

I've looked at the Docs, but unfortunately found no clue, how to adapt to 2.3.1

有人遇到过这个吗?

推荐答案

出现这种情况是因为你关闭了 DMI.method 属性与之前一样与提交标记一起使用,即使在重新发送安全修复后也是如此.使用常量启用 DMI

This happens because you have turned off DMI. The method attribute works with submit tag as before even after resent security fixes. Enable DMI using the constant

<constant name="struts.enable.DynamicMethodInvocation" value="true"/> 

如果它不起作用,请告诉我.

let me know if it didn't work.

相关文章