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 值?
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
