如果标记我如何在struts2中使用请求参数 [英] how can i use request parameter in struts2 if tag

查看:160
本文介绍了如果标记我如何在struts2中使用请求参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样一个链接: http:// localhost:8080 / ESA / login.jsp?login = failed
在上面链接a的末尾设置一个名为 login 的参数,值失败

如何使用此参数带有struts的jsp页面如果是tag。我使用以下代码,但它不起作用。

i have a link like this :http://localhost:8080/ESA/login.jsp?login=failed in end of above link a set a parameter with name login and value failed.
how i can use this parameter in jsp page with struts if tag. I use following code but it don't work.

<s:if test="%{#parameters.login='failed'}">
    <div class="error">
        <s:text name="user.login.failed"></s:text>
    </div>
</s:if>


推荐答案

尝试

<s:if test="%{#parameters.login[0]=='failed'}">

您的代码中存在两个问题:

The two problems were in your code:


  1. = 符号是一项作业,不等于 == ;

  2. 参数在 Map< String,String []> 中保存
    ,因此每个参数都可以有
    多个值,并通过指定索引来访问。

  1. The = sign is an assignment, not equals ==;
  2. Parameters are saved in the Map<String, String[]>, so each parameter could have multiple values and accessed by the specifying an index.

最后一个选项也在这里描述:为什么 if 标签不评估正确的参数

The last option also described here: why doesn't the if tag evaluate params properly.

这篇关于如果标记我如何在struts2中使用请求参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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