如何在Struts迭代器标记中添加条件? [英] How to add a condition in Struts iterator tag?
本文介绍了如何在Struts迭代器标记中添加条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当评级值小于或等于 2
时,我想突出显示一行。我无法使用< s:if>
来获取我的结果。请告诉我如何在我的JSP页面中放置条件。
I want to highlight a row when the value of rating is less than or equal to 2
. I am not able to use the <s:if>
to get my result. Please tell me how to put condition in my JSP page.
<table>
<s:iterator value="fb" status="abc">
<s:if test="#abc.rating==2">
<td style="background: #CCCCCC">
</s:if>
<tr>
<td><s:property value="cid"/></td>
<td><s:property value="cname"/></td>
<td><s:property value="rating"/></td>
<td><s:property value="likes"/></td>
<td><s:property value="dislikes"/></td>
<td><s:property value="suggestion"/></td>
</tr>
</s:iterator>
</table>
推荐答案
有几种方法:
-
物业名称:
property name:
<s:iterator value="mySource">
<s:if test="rating==2">
var
别名参考:
<s:iterator value="mySource" var="myVar">
<s:if test="#myVar.rating==2">
IteratorStatus index:
IteratorStatus index:
<s:iterator value="mySource" status="myStat">
<s:if test="mySource[%{#myStat.index}].rating==2">
top
参考:
<s:iterator value="mySource">
<s:if test="top.rating==2">
这篇关于如何在Struts迭代器标记中添加条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文