我正在尝试遍历项目集合:
<c:forEach items="#{tree.items}" var="item">
<h:commandLink rendered="#{item.type == 'category'}" action="#{item.onNodeClicked}"Hovewer,我有个例外
javax.el.PropertyNotFoundException:类'java.lang.String‘没有属性'type’。
看起来JSP将树项识别为字符串对象。我错过了什么?
发布于 2012-12-17 15:27:14
这不管用。#{item}仅在视图构建时可用,而rendered属性则在视图呈现时进行计算。
使用<c:if>代替。
<c:forEach items="#{tree.items}" var="item">
<c:if test="#{item.type == 'category'}">
<h:commandLink ... action="#{item.onNodeClicked}" />或者,如果您使用的是JSF2 (已经运行了3年以上),请将遗留的JSP替换为后续的Facelets,然后使用它的<ui:repeat>组件。它也是在视图呈现时间内进行评估的。
<ui:repeat value="#{tree.items}" var="item">
<h:commandLink rendered="#{item.type == 'category'}" action="#{item.onNodeClicked}" />https://stackoverflow.com/questions/13916953
复制相似问题