Struts2 的动作类中的动作映射



我正在Struts2(2.5.16(上开发一个应用程序。我遇到了一种情况,我的动作类需要知道它的动作名称(在 struts 中定义.xml(。在 struts1 中,我们可以通过使用mapping.getPath((来实现这一点。我们如何在 struts2 中实现这一目标?

我的支柱.xml:

<action name="testAction" class="action.TestAction">
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>

我想在我的 struts2 动作类中获得">测试动作"。

谢谢 苏尼尔

你试过使用 ActionContext 吗?

String actionName = ActionContext.getContext().getName();

最新更新