循环通过JSTL的地图 [英] Loop through a Map with JSTL

查看:117
本文介绍了循环通过JSTL的地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望JSTL循环通过一个 Map< String,String> 并输出该键的值,它的值。

I'm looking to have JSTL loop through a Map<String, String> and output the value of the key and it's value.

例如,我有一个 Map< String,String> 可以有任意数量的条目,我想循环使用这个地图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的地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆