将一个集合list等分成几个集合
java后台:
//等分的数量
int pageSize = 2;
//list集合的长度
int total = splist.size();
//等分循环的次数
int pageCount = total % pageSize == 0 ? total / pageSize : total / pageSize + 1;
//循环等分循环的次数
for(int i = 0; i < pageCount; i++) {
Map<Integer,List<MxxzWebsitComment>> tmpMap =new HashMap();
int start = i * pageSize;//从哪里开始取数据
int end = start + pageSize > total ? total : start + pageSize;
List<MxxzWebsitComment> subList = splist.subList(start, end);
tmpMap.put(i, subList);
tmpList.add(tmpMap);
}
//前台循环
<c:forEach items="${splist}" var="map" varStatus="status">
<ul>
<c:forEach items="${map}" var="entry">
<c:forEach items="${entry.value}" var="comment">
<li>
<a href="menuDetail.htm?mwmId=${comment.mwmId}">
<img style="height:81px;width:115px;" src="${comment.rootNewsIconFilePath}" />
</a>
</li>
</c:forEach>
</c:forEach>
</ul>
</c:forEach>