基于堆内存,先把map放到返回值里
Map _map=new HashMap(); modelAndView.addObject("pledgeInsurance",_map);//先把map放到返回值里 for(YsPledge pledge :iPmYsPledgeList){ //查询保险信息 List<YsPledgeInsurance> iPmYsPledgeInsurances = iYsPledgeService.ysPledgeInsuranceByPId(pledge.getId(),sourcedb); pledgeInsurance.addAll(iPmYsPledgeInsurances); _map.put("pledgeInsurance"+pledge.getId(),iPmYsPledgeInsurances);//在循环中把list对象放到定义好的map参数中,动态key里加id modelAndView.addObject("pledgeInsuranceArray", JSONArray.fromObject(pledgeInsurance).toString()); //查询评估信息 List<YsPledgeLog> PledgeLog = iYsPledgeService.ysPledgeLogByPId(pledge.getId(),sourcedb); ysPledgeLogList.addAll(PledgeLog); _map.put("ysPledgeLogList"+pledge.getId(),PledgeLog); modelAndView.addObject("ysPledgeLogListArray", JSONArray.fromObject(ysPledgeLogList).toString()); }
el表达式用c:set先取map拼接的key,在c:foreach取map的key【set的变量】
<c:set var="in" value="pledgeInsurance${pledge.id}"/> <c:forEach items="${pledgeInsurance[in]}" var="insurance" varStatus="insuranceSta"> </c:forEach>