[基础]Map在JSP中的两种显示方式

来源:互联网 发布:大数据的数据来源 编辑:程序博客网 时间:2024/05/17 07:44

1、

Java:

  for(EglSpecialRequest req : list){for(String idStr : ids){if(StringUtils.isEmpty(idStr)) continue;Integer id = Integer.parseInt(idStr);if(id - req.getId() == 0){idsMap.put(req.getId(), req.getRequestNameEn());}}}return idsMap;bookingHotelForm.set("idsMap", idsMap);

 JSP:

  <c:forEach items="${SPECIAL_REQUEST_LIST}" var="req"><c:set value="${req.id}" var="key"/><c:if test="${req.type == '3'}">${empty bookingHotelForm.map.idsMap[key] ? "" : bookingHotelForm.map.idsMap[key]}${empty bookingHotelForm.map.timeDateMap[key] ? "" : bookingHotelForm.map.timeDateMap[key]}<c:if test="${!empty bookingHotelForm.map.idsMap[key]}"><br><br></c:if></c:if></c:forEach>

 

2、

Form:

   <form-property name="testMap" type="java.util.Map" />

Java:

 Map<String, String> testMap  = new HashMap<String, String>(); for (int i = 0; i < packageMiscellaneousList.size(); i++) {PackageMiscellaneous packageMiscellaneous = packageMiscellaneousList.get(i);supplierCode.put(i+"", packageMiscellaneous.getSupplierCode());testMap.put(i+"", "TestNo"+i);}packageMiscellaneousForm.set("testMap", testMap );

 JSP:

 <c:forEach items="${packageMiscellaneousForm.map.testMap}" var="item" varStatus="i"><tr><td><html:select property="supplierCode(${i.index})" styleId="supplierCode_${i.index}"><html:option value="">--Please select supplier--</html:option><c:forEach items="${SUPPLIER_LIST}" var="supplier"><html:option value="${supplier.suppliercode}">${supplier.suppliername }</html:option></c:forEach></html:select></td><td><html:text property="testMap(${i.index})" styleId="testMap_${i.index}"></html:text></td></tr></c:forEach>

 。。。

 

 

 

 

 

 

 

 

 

 

 

0 0