java动态返回一个大对象里多个小对象map返回,el表达式用c:set拼接

基于堆内存,先把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>

  

原文地址:https://www.cnblogs.com/gaobing1252/p/8565669.html