public String putListToMap(){
List<Person> personList = new ArrayList<Person>();
Person p= null;
for (int i
= 0; i < 50; i++) {
p= new Person();
if(i%3==0){
p.setPid( "aa");
p.setUsername( "P"+i);
}
if(i%3==1){
p.setPid( "bb");
p.setUsername( "p"+i);
}
if(i%3==2){
p.setPid( "cc");
p.setUsername( "p"+i);
}
personList.add(p);
}
ActionContext. getContext().put("pList",
personList);
return "list_map" ;
}
|
<style type= "text/css">
.odd{
background-color:red ;
}
.even{
background-color:blue ;
}
.blue{
background-color:yellow ;
}
.red{
background-color:red ;
}
</style >
<s:iterator value= "#pList" var ="aa" status="statu">
<!-- 每三行变色 status 使用s:debug可以查看到该类为IteratorStatus
-->
<tr class= "<s:property value="#statu.index%3==0?‘blue‘:‘red‘" />">
<%--<tr class="<s:property
value="#statu.even?‘even‘:‘odd‘"/>">
--%>
<td>
<s:property value= "pid"/>
</td>
<td>
<s:property value= "username"/>
</td>
<td>
<s:property value="#statu.count" />
</td>
<td>
<s:if test= "#statu.odd">
奇数行
</s:if>
<s:elseif test= "#statu.even">
偶数行
</s:elseif>
</td>
<td>
<s:property value="#statu.index" />
</td>
<td>
<s:if test="pid==‘aa‘||pid==‘bb‘" >
<input type= "button" name="adsf" value="修改">
</s:if>
</td>
<td>
<s:if test="pid==‘cc‘||pid==‘aa‘" >
<input type= "button" name="adsf" value="删除">
</s:if>
</td>
</tr>
</s:iterator>
|
版权声明:本文为博主原创文章,未经博主允许不得转载。
【Struts2五】ValueStack以及ognl表达式二(常用标签)
原文地址:http://blog.csdn.net/damogu_arthur/article/details/46907531