问题描述
我尝试使用 p>
确保你的一切都正确。您的特殊问题是由于#{repcatTree.items} 未被解释为EL表达式,而是作为纯字符串,表明EL在JSTL中根本不起作用,这反过来表明你可能使用JSTL 1.0 / 1.1(注意Glassfish已经捆绑了JSTL,所以你不应该随你的webapp一起发布),或者使用JSTL 1.0 taglib URI而不用 / jsp 路径或者 web.xml 未声明符合Servlet 2.5。
另见:
- - 包含下载链接和安装说明
I am trying to iterate over a collection of elements, which are complex types (another entities) using <c:forEach>:
<c:forEach items="#{repcatTree.items}" var="item"> <div style="padding-top:7px; padding-bottom:7px; padding-right:15px;"> <span class="report_item_category_class"> <h:commandLink rendered="#{item.type == 'category'}" action="#{item.onNodeClicked}" styleClass="default_link"> <h:graphicImage url="/views/tree/images/folder_big.gif" /> <h:outputText value="#{item.attributes.FILE_NAME}" style="font-size:14px; font-weight:bold; padding-left:5px" /> </h:commandLink> <h:commandLink rendered="#{item.type == 'report'}" styleClass="default_link" action="action_report_run" title="#{item.cells['report_name'].toolTip}"> <h:graphicImage url="/icon?rdd_path=#{item.attributes.RDD_PATH}" /> <h:outputText value="#{item.cells['report_name'].display}" style="font-size:14px; font-weight:bold; padding-left:5px" /> <f:param name="nodePath" value="#{item.attributes.RDD_PATH}" /> <f:param name="nodePrettyPath" value="#{item.attributes.CAT_PATH}" /> </h:commandLink> </span> </div> </c:forEach>
However, inside of forEach block logic treats '#{item}' element as a regular java.lang.String causing
Here's my faces-config.xml (JSF 1.2) related mapping entry:
<managed-bean> <managed-bean-name>repcatTree</managed-bean-name> <managed-bean-class>rpt.engine.runner.tree.impl.RepcatTreeModel</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>path</property-name> <property-class>java.lang.String</property-class> <value>/</value> </managed-property> <managed-property> <property-name>listener</property-name> <property-class>rpt.engine.runner.tree.listeners.ReportsTreeModelListener</property-class> <value>#{reportsTreeModelListener}</value> </managed-property> <managed-property> <property-name>tableModel</property-name> <property-class>rpt.engine.runner.table.TableModel</property-class> <value>#{repcatTableModel}</value> </managed-property> </managed-bean>
How is this caused and how can I solve it?
That can happen if you used the wrong JSTL version for the environment or used the wrong JSTL taglib URI declaration.
JSF 1.2 implies a minimum of Servlet 2.5 (your webapp's web.xml must also be declared as such!), which in turn implies a minimum of JSTL 1.2, which in turn implies a taglib URI of http://java.sun.com/jsp/jstl/core.
Make sure you got everything right. Your particular problem is caused because #{repcatTree.items} is not interpreted as an EL expression, but instead as plain string, indicating that EL in JSTL doesn't work at all, which in turn indicates that you're possibly using JSTL 1.0/1.1 (note that Glassfish already bundles JSTL, so you should not ship any along with your webapp), or used the JSTL 1.0 taglib URI without the /jsp path, or the web.xml is not declared conform Servlet 2.5.
See also:
- Our JSTL wiki page - contains download links and installation instructions
这篇关于c为C:的forEach>将项目属性视为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!