<% List<Object[]> city=(List<Object[]>)request.getAttribute("list"); for(Object[] row:city){ %> <tr> <td width="404"> <font color="#000000"><a href="#"><%=row[0] %></a> </font> </td> <td width="202"> <font color="#000000"><%=row[1] %></font> </td> <td width="258"> <font color="#000000"><%=row[2] %></font> </td> </tr> <% } %>
后台list 代码
public List<Object[]> getAllInfos() { List<Object[]> list = new ArrayList<Object[]>(); // 配置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; }