struts2 标签实战整理

来源:互联网 发布:java做cs 编辑:程序博客网 时间:2024/06/04 18:53

List中存放一个Map,利用<s:iterator/>标签显示例子如下:

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

#hashMap.seatseat是Map中的key。

  1.      < s:iterator   value = "detailList"   id = "hashMap" >
  2.          < tr >
  3.              < td > < s:property   value = "#hashMap.seat"   />   </ td >
  4.              < td > < s:property   value = "#hashMap.specialOffer"   />   </ td >
  5.              < td > < s:property   value = "#hashMap.price"   />   </ td >
  6.              < td > < s:property   value = "#hashMap.preferentialPrice"   />   </ td >
  7.              < td > < s:property   value = "#hashMap.returnPoint"   />   </ td >
  8.              < td > < s:property   value = "#hashMap.remainMoney"   />   </ td >
  9.              < td > < s:property   value = "#hashMap.direction"   />   </ td >
  10.              < td > < s:property   value = "#hashMap.releaseMan"   />   </ td >
  11.              < td > < input   type = "button"   value = "订票" > </ input >   </ td >
  12.          </ tr >
  13.      </ 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>