如图这样显示:
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
Map<String,Object> map = null;
List<Map<String, Object>> all= biz.getAllProvinces();
for (int i = 0; i < allProvinces.size(); i+=3) {
map = new HashMap<String, Object>();
for(int j = i; j < i+3 && j < <span style="font-family: Arial, Helvetica, sans-serif;">all</span><span style="font-family: Arial, Helvetica, sans-serif;">.size(); j++){</span>
String unicode = all.get(j).get("unicode").toString();
String name = all.get(j).get("name").toString();
if((j+1)%3==1){
map.put("unicode1", unicode);
map.put("name1", name);
}else if((j+1)%3==2){
map.put("unicode2", unicode);
map.put("name2", name);
}else{
map.put("unicode3", unicode);
map.put("name3", name);
}
}
list.add(map);
}
request.setAttribute("list", list);
return "forward:/jsp.jsp";
页面:
<c:forEach items="${list }" var="result" varStatus="status" >
<ul class="lineTwo">
<li style="width:10%" class="minFirst first">
<input type="checkbox" id="${result.unicode1 }" name="id" value="${result.unicode1}">
</li>
<li style="width:23%">${result.name1}</li>
<c:if test="${not empty result.unicode2}">
<li style="width:10%" class="minFirst first">
<input type="checkbox" id="${result.unicode2}" name="id" value="${result.unicode2}">
</li>
<li style="width:23%">${result.name2}</li>
</c:if>
<c:if test="${not empty result.unicode3}">
<li style="width:10%" class="minFirst first">
<input type="checkbox" id="${result.unicode3}" name="id" value="${result.unicode3}">
</li>
<li style="width:23%">${result.name3}</li>
</c:if>
</ul>
</c:forEach>