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>