struts2标签的遍历数据库查询后的数组list

1,标签的加入

<%@ taglib uri="/struts-tags" prefix="s" %>,

2,数据格式:List<Object[]>   应用是在使用hibernate查询数据库后返回的list。

3,action中代码:

private List cityCodeList;

public List getCityCodeList() {
  return cityCodeList;
 }
 public void setCityCodeList(List cityCodeList) {
  this.cityCodeList = cityCodeList;
 }

public String findScheduleCityCode() {
  try {
   cityCodeList = this.systemService.findScheduleCityCode();
  } catch (Exception e) {
   e.printStackTrace();
  }
  return "CITYCODE";
 }

4,JSP中遍历代码:

<s:iterator value="cityCodeList" id="city1" status="city">
<s:if test="%{#city.index==0}">
<tr class="tr2">
</s:if>
<s:if test="%{(#city.index+1)%15==0&&#city.index!=0}">
 </tr>
 <tr class="tr2">
 </s:if>
 <s:else>
    <td title=<s:property value="cityCodeList[#city.index][1]"/> οnclick="showCityName(this);">
    <s:property value="cityCodeList[#city.index][0]"/></td>
 </s:else>
</s:iterator>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值