简体   繁体   English

如何在JSP中访问AbstractMap.SimpleEntry的值?

[英]How to access values of AbstractMap.SimpleEntry in JSP?

For example, I have 例如,我有

List<SimpleEntry<String, String>> myPairList = 
                                   new ArrayList<SimpleEntry<String, String>>();

How do I access its entries (the key and the value) through 如何通过访问其条目(密钥和值)

<c:forEach items="${myList }" var="myPair">
   <c:set var="key" value="????????" />
   <c:set var="value" value="????????" />
</c:forEach>

What does the javadoc say about the class SimpleEntry? javadoc对SimpleEntry类有什么看法? It has a getKey() getter, and a getValue() getter. 它有一个getKey() getter和一个getValue() getter。

How do we access a property (ie a getter) from the JSP EL? 我们如何从JSP EL访问属性(即getter)? obj.propertyName

So you just need 所以你需要

<c:set var="key" value="${myPair.key}" />
<c:set var="value" value="${myPair.value}" />    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM