Struts 2 <s:if>标签如何获取要在jsp中评估的动作名称 [英] Struts 2 <s:if> tag How to get action name to be evaluated in jsp

查看:18
本文介绍了Struts 2 <s:if>标签如何获取要在jsp中评估的动作名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,如果我在 Struts2 中使用 <s:if> 标记,我可以获得任何想要的结果

Now I can get any desired results if I use the <s:if> tag in Struts2

    <s:if test="status==1">
         //do some stuff
    </s:if>

但我不知道如何让当前执行的动作,我期待像

but I don't know how to get the action currently executed, I am expecting like

    <s:if test="action==addaction">
         //do some stuff
    </s:if>

推荐答案

可以从上下文中获取动作名称

You can get action name from the context

<s:if test="#context['struts.actionMapping'].name=='addaction'">
   do some stuff
</s:if>

这篇关于Struts 2 &lt;s:if&gt;标签如何获取要在jsp中评估的动作名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆