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 值?
基础教程推荐
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
