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 值?
基础教程推荐
- 将 Windows 证书导入 Java 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 将 double 转换为 Int,向下舍入 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
