如何展示model本身是list,list下的每个值都是map。
?????? 请参考如下:
????? (1.1) JSP 代码
?
?<c:forEach items="${testList}" var="testMap" varStatus="status">
?<td>11111</td>
?<c:forEach var="mapItem" items="${testMap}">?
?<c:if test="${mapItem.key =='name'}">
???? <td>name:<c:out value="${mapItem.value}"/></td>
?</c:if>
?<c:if test="${mapItem.key =='age'}">????
???? <td>age:<c:out value="${mapItem.value}"/></td>
?</c:if>
?</c:forEach>
?<td align="right"><c:out value="${liuTest}"/></td>
?</tr>
?</c:forEach>
??? (请注意:里面使用了两次forEach,一次用来获取list中某个元素,一次用于获取Map中的entry)
?
??? (1.2) 对应Java程序代码
???????????? Map model = serviceResponse.getModel();
???????????? model.put("liuTest",new BigDecimal(5));???????????
???????????? System.out.println("model--- 111? ---- is :"+model);
???????????? HashMap hsm=new HashMap();
???????????? HashMap hsm2=new HashMap();
???????????? hsm.put("name","testName1");
???????????? hsm.put("age","testAge1");
???????????? hsm2.put("name","testName2");
???????????? hsm2.put("age","testAge2");
???????????? ArrayList alist=new ArrayList();
???????????? alist.add(hsm);
???????????? alist.add(hsm2);
???????????? model.put("testList",alist);
???????????? System.out.println("model is :"+model);
???????????? return new ModelAndView(getFormView(), model);
说明: 如果model中存在一些非java.lang或者java.math中的类,一定要 使用import 将类导进来。