一:先创建一个封装集合的实体类
package com.cm.supermarket.pojo.base;
import java.util.List;
/**
* list实体类
*/
public class ListProperties {
private String key;
private List<PageData> valueList;
public void setKey(String key) {
this.key = key;
}
public String getKey() {
return key;
}
public void setValueList(List<PageData> valueList) {
this.valueList = valueList;
}
public List<PageData> getValueList() {
return valueList;
}
}
二:遍历嵌套集合放入父集合
List<ListProperties> ppList = new ArrayList<ListProperties>();
List<List<PageData>> listListPageDatas = split(pd,14);
ListProperties listProperties = null;
int key = 0;
for (List<PageData> pp : listListPageDatas) {
listProperties = new ListProperties();
listProperties.setValueList(pp);
listProperties.setKey(key+"");
key++;
ppList.add(listProperties);
}
mv.addObject("pd",ppList);
三:jsp中进行遍历
<div class="bd" style="margin-top:16px;display: flex; flex-direction: column;justify-content: space-evenly;">
<c:forEach items="${pd}" var="var" varStatus="vs">
<c:set value="${var.valueList }" var="var2"/>
<ul name="${var.key}" class="clearfix" style="display: flex;flex-direction: row;flex-wrap: wrap;">
<c:forEach items="${var2}" var="varC" varStatus="vs">
<li style="width: 140px;display: block; padding: 10px;margin: 10px auto;">
<div style="">
<a href="javascript: void(0);" @click="ServiceClass('${varC.DICTIONARIES_ID}')"
style="display: flex;flex-direction: column;align-items: center;justify-content: space-evenly;">
<!--todo 图片-->
<img tyle="width: 90px;" src="${varC.logo1}" alt="">
<p style="margin-top:4px;">${varC.NAME}</p>
</a>
</div>
</li>
</c:forEach>
</ul>
</c:forEach>
</div>