使用 JSTL 遍历 Map [英] Loop through a Map with JSTL
本文介绍了使用 JSTL 遍历 Map的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望通过 Map
进行 JSTL 循环并输出键的值及其值.
I'm looking to have JSTL loop through a Map<String, String>
and output the value of the key and it's value.
例如,我有一个 Map
,它可以有任意数量的条目,我想使用 JSTL 遍历这个映射并输出键和它的值.
For example I have a Map<String, String>
which can have any number of entries, i'd like to loop through this map using JSTL and output both the key and it's value.
我知道如何使用密钥${myMap['keystring']}
访问该值,但是我如何访问该密钥?
I know how to access the value using the key, ${myMap['keystring']}
, but how do I access the key?
推荐答案
像这样:
<c:forEach var="entry" items="${myMap}">
Key: <c:out value="${entry.key}"/>
Value: <c:out value="${entry.value}"/>
</c:forEach>
这篇关于使用 JSTL 遍历 Map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文