日期:2014-05-17 浏览次数:21019 次
List<Map<String,String>> list = new ArrayList<Map<String,String>>(); Map map = new HashMap(); map.put("e_name","zhangsan"); map.put("c_name","张三"); map.put("bth_day","19811224"); map.put("sex","女"); list.add(map); map = new HashMap(); map.put("e_name","lisi"); map.put("c_name","李四"); map.put("bth_day","19770805"); map.put("sex","男"); list.add(map); map = new HashMap(); map.put("e_name","wangwu"); map.put("c_name","王五"); map.put("bth_day","19830924"); map.put("sex","女"); list.add(map);
------解决方案--------------------
<%@ page language="java" import="task6.MyList,java.util.List" pageEncoding="UTF-8"%> <HTML> <BODY> <jsp:useBean id="mylist" scope="application" class="task6.MyList" > </jsp:useBean> <H3>MyList scope="request" Example</H3> <table border=1> <tr> <td> 英文</td> <td> 中文</td> <td> 生日</td> <td> 性别</td> </tr> <% List list = mylist.getList() ; int idx1 = 0; int idx2 = 1; int idx3 = 2; int idx4 = 3; int len = list.size() / 4; for (int i = 0; i < len -1; i++){ %> <tr> <td><%=(String)list.get(idx1)%></td> <td><%=(String)list.get(idx2)%></td> <td><%=(String)list.get(idx3)%></td> <td><%=(String)list.get(idx4)%></td> </tr> <% idx1 +=4 ; idx2 +=4 ; idx3 +=4 ; idx4 +=4 ; } %> </table> </BODY> </HTML>
------解决方案--------------------
<body>
<table border="1px&qu