如何在jsf中显示hashmap值? [英] How to show hashmap values in jsf?
问题描述
我有beanMyBean,它具有属性HashMap - map,其值类型是MyClass。我想使用ui在jsf中显示地图的一些属性:repeat。
但这些代码:
I have bean "MyBean", which has property HashMap - "map" which values type is MyClass. I want to show some properties of map in jsf using ui:repeat. But these code:
<ui:repeat var="var" value="#{mybean.map}" >
<tr>
<td> <h:outputText value="#{var.value.property1}"></h:outputText> </td>
<td><h:outputText value="#{var.value.property2}"></h:outputText></td>
</tr>
</ui:repeat>
但是这段代码没有显示任何内容。尽管当我尝试以这种方式在jsp中显示hashmap值时,它是成功的。我错在哪里?如何解决这个问题?
But this code didn't show anything. Though when I try to show hashmap values in jsp this way, it was succesfull. Where I am wrong? And how fix that?
推荐答案
从文档为 repeat
值属性:
该标记迭代的项目集合的名称。该集合可以是
List
,数组,java.sql.ResultSet
,或者是一个单独的java对象
。如果collection为null,那么这个标签什么都不做。
The name of a collection of items that this tag iterates over. The collection may be a
List
, array,java.sql.ResultSet
, or an individual javaObject
. If the collection is null, this tag does nothing.
所以,var被设置为 HashMap
,并且EL尝试在其上查找关键字
value
。您需要将您的输入集公开为 List
。
So, var is set as your HashMap
and EL tries to look up the key "value"
on it. You will need to expose your entry set as a List
.
这篇关于如何在jsf中显示hashmap值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!