日期:2014-05-17  浏览次数:20712 次

怎么在jsp中读取action中的Map集合里面的值呢?
怎么在jsp中读取action中的Map集合里面的值呢?Map集合是{value=12|22|1|21,text=你|我|他}这种格式的。请问怎么在jsp里面获取value和text对应的值呢?
------解决方案--------------------
用el表达式${map['key']}
------解决方案--------------------
<c:forEach var="map" items="${systemList}">
<c:forEach items="${map}" var="entry">
<c:choose>
<c:when test="${system==entry.key}">
<option value="${entry.key}" selected="selected">
${entry.value}
</option>
</c:when>

<c:otherwise>
<option value="${entry.key}">
${entry.value}
</option>
</c:otherwise>
</c:choose>

</c:forEach>
</c:forEach>
</select>
------解决方案--------------------
上边的是遍历MAP的
<%
String postcode = "34:5873:9898:001";
request.setAttribute("mypostcode", postcode);
%>

<c:forTokens items = "${mypostcode}" delims = ":" var = "item">
${item}
</c:forTokens>

这个是遍历字符串,一某个字符为分割符。

结合一起就可以遍历了。