【发布时间】:2018-06-18 07:15:57
【问题描述】:
我正在 Struts2(2.5.16) 上开发一个应用程序。我遇到了一种情况,我的动作类需要知道它的动作名称(在 struts.xml 中定义)。在struts1中,我们可以使用mapping.getPath()来实现。我们如何在 struts2 中实现这一点?
我的 struts.xml:
<action name="testAction" class="action.TestAction">
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
我想在我的 struts2 动作类中获得“testAction”。
谢谢, 苏尼尔
【问题讨论】:
-
是什么原因?一般来说,由于各种原因,一个动作不需要知道它叫什么。也许有更好的解决方案。
标签: struts2