<c:set var="companyName" value="${companymap['company']}" scope="request"></c:set>spa
将el表达式的值setAttribute中,而后就能够在代码中直接使用companyName变量code
EL表达式取片断值:orm
将代码片断中的属性或者集合setAttribute中,而后在页面EL表达式中获取${**}获取就行get
片断取EL表达式值:it
request.getAttribute("companyName") == EL表达式${companyName} io
eg:form
//获取后台传过来的集合,取出其中重复的公司名称的项,并将(公司名,出现次数)放入map中,而后再存入页面中。 List<Map<String,String>> companyinformationLists = (List<Map<String,String>>)request.getAttribute("companyinfoLists"); Map<String, Integer> map = new HashMap<String, Integer>(); if(companyinformationLists != null){ for(int i = 0; i < companyinformationLists.size(); i++){ if(!map.containsKey(companyinformationLists.get(i).get("company"))){ map.put(companyinformationLists.get(i).get("company"),1); }else{ map.put(companyinformationLists.get(i).get("company"),1+map.get(companyinformationLists.get(i).get("company"))); } } request.setAttribute("map",map); } <c:forEach var="companymap" items="${companyinfoLists}" varStatus="companynum"> <c:choose> <c:when test="${map[companymap['company']] > 1}"> <tr> <c:set var="companyName" value="${companymap['company']}" scope="request"></c:set> <td width="22%" rowspan="${map[companymap['company']]}">${companymap['company']}</td> <td width="8%">${companymap['month']}</td> <td width="15%" rowspan="${map[companymap['company']]}">${companymap['agreementsystem']}</td>