来自 <action> 元素的属性参数 - 在 Struts 2 中等效

Attribute parameter from <action> element - equivalent in Struts 2

在 Struts1 中,您可以使用元素 (struts-config.xml) 中的属性 参数 并在操作 class 通过 actionMapping.getParameter() 方法。对于需要多步的动作,常使用参数表示映射关联到哪一步 与.

例如:

<action path="\something\Step1"
type="actions.SomethingAction"
parameter="step1"> ...

<action path="\something\Step2"
type="actions.SomethingAction"
parameter="step2"> ...

Struts2 的替代解决方案是什么?

可以改用动作配置中的参数

<package name="something" namespace="/something" extends="struts-default">
  <action name="Step1" class="actions.SomethingAction">
    <param name="step1" ...
  </action>
  <action name="Step2" class="actions.SomethingAction">
    <param name="step2" ...
  </action>
</package>