您的位置:首页 > 编程语言 > Java开发

struts2 标签实战整理

2011-08-20 16:50 435 查看
List中存放一个Map,利用<s:iterator/>标签显示例子如下:

其中detailList是List的名字(必须和后台返回的List名字相同),hashMap是其中存放的Map的一个代号。

#hashMap.seat中seat是Map中的key。

< s:iterator value = "detailList" id = "hashMap" >
< tr >
< td > < s:property value = "#hashMap.seat" /> </ td >
< td > < s:property value = "#hashMap.specialOffer" /> </ td >
< td > < s:property value = "#hashMap.price" /> </ td >
< td > < s:property value = "#hashMap.preferentialPrice" /> </ td >
< td > < s:property value = "#hashMap.returnPoint" /> </ td >
< td > < s:property value = "#hashMap.remainMoney" /> </ td >
< td > < s:property value = "#hashMap.direction" /> </ td >
< td > < s:property value = "#hashMap.releaseMan" /> </ td >
< td > < input type = "button" value = "订票" > </ input > </ td >
</ tr >
</ s:iterator >

对于careerpersonList

[

{cp_url=null, cp_id=1, cp_title=www, cp_content=wwwwwww,
cp_pubtime=2011-08-13, cp_author=admin, cp_filename=null},

{cp_url=null, cp_id=2, cp_title=hc, cp_content=hchchc,
cp_pubtime=2011-08-18, cp_author=admin, cp_filename=null},

{cp_url=null, cp_id=3, cp_title=zx, cp_content=zxzxzx,
cp_pubtime=2011-08-17, cp_author=admin, cp_filename=null},

{cp_url=null, cp_id=4, cp_title=yf, cp_content=yfyfyf,
cp_pubtime=2011-08-16, cp_author=admin, cp_filename=null},

{cp_url=null, cp_id=5, cp_title=fys, cp_content=ssssfffsssyyy,
cp_pubtime=2011-08-15, cp_author=admin, cp_filename=null}

]
迭代输出

<s:iterator value="careerpersonList"
status="sta">

<s:property
value="#sta.getIndex()+1" />:

<s:iterator>

<s:a
url="#">

<span
class="colorize">

<s:if
test="key=='cp_title'">

<s:property
value="value.substring(0,2)"/>

</s:if>

</span>

</s:a>

</s:iterator>

<br
/>

<hr
/>

</s:iterator>

<s:iterator
value="careerpersonList" status="sta" id="cl">

<s:property value="#cl.cp_title.substring(0,8)" /><br/><hr/>

</s:iterator>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: