How to show hashmap values in jsf?(如何在 jsf 中显示 hashmap 值?)
问题描述
我有 bean MyBean",它有属性 HashMap - map",它的值类型是 MyClass.我想使用 ui:repeat 在 jsf 中显示地图的一些属性.但是这些代码:
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 值属性的 pdldocs/facelets/ui/repeat.html">文档:
From the documentation for the repeat value attribute:
此标记迭代的项目集合的名称.集合可以是 List、数组、java.sql.ResultSet 或单独的 java Object.如果集合为空,则此标签不执行任何操作.
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 值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 jsf 中显示 hashmap 值?
基础教程推荐
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 大摇大摆的枚举 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
