[英]how can i use request parameter in struts2 if 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
. 我有一个这样的链接: http://localhost:8080/ESA/login.jsp?login=failed
在上面的链接结束时http://localhost:8080/ESA/login.jsp?login=failed
一个设置名称login
和值的参数failed
。
how i can use this parameter in jsp page with struts if tag. 我如何在带有struts的jsp页面中使用此参数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>
Try with 试试吧
<s:if test="%{#parameters.login[0]=='failed'}">
The two problems were in your code: 这两个问题出在你的代码中:
=
sign is an assignment, not equals ==
; =
符号是一个赋值,而不是等于==
; Parameters are saved in the Map<String, String[]>
, so each parameter could have multiple values and accessed by the specifying an index. 参数保存在Map<String, String[]>
,因此每个参数可以有多个值,并通过指定索引来访问。
The last option also described here: why doesn't the if
tag evaluate params properly . 最后一个选项也在这里描述: 为什么if
标签不能正确评估params 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.