开发者

Get value of HashMap by specific key in EL without iterating over it

I want to read data from a HashMap using EL in a JSP page, but without t开发者_开发知识库he use of JSTL <c:forEach> or a for loop. How can I do this?


Just use the map key as if it were a bean property:

${map.key}

This does under the covers the same as map.get("key").


Or via the brace notation if the key contains dots:

${map['key.with.dots']}

This does under the covers the same as map.get("key.with.dots").


Or if the key is another variable:

${map[dynamicKey]}

This does under the covers the same as map.get(dynamicKey).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜