本文章整理了很多的jsp 页面的for循环示例程序,如果你对于java循环不怎么了解不防进入参考一下,非常全面的一篇文章
例子1
代码如下 | 复制代码 | |
List city=(List)request.getAttribute("list"); for(Object[] row:city){ %> |
||
%>
后台list 代码
代码如下 | 复制代码 | ||||
public List getAllInfos() { List list = new ArrayList(); // 配置sql代码 String sql = "select CityInfo.cityInfoContent,TypeInfo.typeInfoName, CityInfo.cityInfoDataTime from TypeInfo,CityInfo where CityInfo.typeInfoID=TypeInfo.typeInfoID"; Object[] obj = null; Result result = cityInfoDao.runSelect(sql, obj); if (result != null & result.getRowCount() > 0) { Map[] maps = result.getRows(); for (Map row : maps) { String cityInfoContent = row.get("cityInfoContent").toString(); String typeInfoName = row.get("typeInfoName").toString(); String cityInfoDataTime = row.get("cityInfoDataTime").toString(); Object[] objects = { cityInfoContent, typeInfoName, cityInfoDataTime }; list.add(objects); } } return list; } 例子2
|