Map在jsp页面中的遍历(Map<String, List<T>>)

来源:互联网 发布:儿童学编程好不好 编辑:程序博客网 时间:2024/05/29 10:55

JAVA代码

if(StringUtil.isNotNull(businessId)){List<AppProjPropLink> linkList = projTypeService.getCusPropByProjTypeId(businessId, metaCode);Map<String, List<AppProjPropLink>> map = new HashMap<String, List<AppProjPropLink>>();for (AppProjPropLink appProjPropLink : linkList) {if(!StringUtil.isNotNull(appProjPropLink.getMetaProp().getDictSelfGroup())){if(!StringUtil.isNotNull(map.get("未分组"))){List<AppProjPropLink> tempList = new ArrayList<AppProjPropLink>();tempList.add(appProjPropLink);map.put("未分组", tempList);}else{List<AppProjPropLink> tempList = map.get("未分组");tempList.add(appProjPropLink);map.put("未分组", tempList);}}else{if(!StringUtil.isNotNull(map.get(appProjPropLink.getMetaProp().getDictSelfGroup().getName()))){List<AppProjPropLink> tempList = new ArrayList<AppProjPropLink>();tempList.add(appProjPropLink);map.put(appProjPropLink.getMetaProp().getDictSelfGroup().getName(), tempList);}else{List<AppProjPropLink> tempList = map.get(appProjPropLink.getMetaProp().getDictSelfGroup().getName());tempList.add(appProjPropLink);map.put(appProjPropLink.getMetaProp().getDictSelfGroup().getName(), tempList);}}}model.addAttribute("map", map);}

js代码
<form id="propertyListForm" method="post">    <input type="hidden" name="projTypeId" id="projTypeId" value="${businessId}"/>    <table align="center" width="100%">    <tr>    <td width="40%">属性名称</td>    <td width="30%">是否选择</td>    <td width="30%">是否必填</td>    </tr>    </table>    <c:forEach items="${map}" var="entry">    <fieldset>    <legend>${entry.key}:</legend>    <table align="center" width="100%">    <c:forEach items="${entry.value }" var="link">    <tr>    <td width="40%"><label>${link.metaProp.name}</label></td>    <td width="30%"><input type="checkbox" name="isChecked" value="${link.metaProp.id}" <c:if test="${link.id ne null}">checked="checked"</c:if> onclick="setDisabled('${link.metaProp.id}')"/></td>    <td width="30%"><input id="${link.metaProp.id}" type="checkbox" name="isRequired" <c:if test="${link.id eq null}">disabled="true"</c:if> <c:if test="${link.isRequired eq '1'}">checked="checked"</c:if>/></td>    </tr>    </c:forEach>    </table></fieldset></c:forEach>    </form>