Struts2之页面取得当前actionName

在页面上加入<s:debug />, 我们就可以查看stackContext的信息

其中有一项:Key为com.opensymphony.xwork2.ActionContext.name里面保存的就是actionName

直接使用<s:property value="com.opensymphony.xwork2.ActionContext.name" />就可以得到

常用例:

<s:set name="actionName" value="com.opensymphony.xwork2.ActionContext.name" >

<s:if test="#actionName=='recommendReg'">

doSomeThings

</s:if>

<s:else>

doOtherThings

</s:else>

以下为<s:debug />,片段

com.opensymphony.xwork2.dispatcher.HttpServletRequest org.apache.struts2.dispatcher.StrutsRequestWrapper@1ae7f61
com.opensymphony.xwork2.ActionContext.locale en_US
com.opensymphony.xwork2.dispatcher.HttpServletResponse com.opensymphony.module.sitemesh.filter.PageResponseWrapper@12cc880
com.opensymphony.xwork2.ActionContext.name recommendReg
原文地址:https://www.cnblogs.com/firstdream/p/2377653.html