我添加了 2 个托管 Bean: ProductController 有 2 个方法:
ist<ProdusDTO> getList()
String update()
和 ProductDTO,用于实体产品。
index.jsp
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<h:dataTable value="#{ProductController.getList()}" var="p">
<h:column>
<f:facet name="header">Description</f:facet> #{p.description}
</h:column>
<h:column>
<f:facet name="header">Image</f:facet> #{p.image}
</h:column>
</h:dataTable>
<h2>Adds</h2>
<h:form>
<h:panelGrid columns="3">
Description: <h:inputText value="#{produsDTO.description}" size="100" required="true"></h:inputText>
Image: <h:inputText value="#{productDTO.image}" size="100" required="true" label="Image"> </h:inputText>
</h:panelGrid>
<h:commandButton value="Submit" action="#{ProductController.update()}" />
</h:form>
当我运行 jsp 文件时,出现此错误:
PWC6228: #{...} not allowed in a template text body.
在构建路径中,我包含了 jsf-api.jar 和 jsf-impl.jar (mojjara 1.2_15)
为什么我无法为 dataTable 组件指定 value 属性的方法?
谢谢。
最佳答案
统一表达语言deferred expressions仅允许在支持它们的自定义标记属性中使用(请参阅 JSP 2.1 了解 UEL 支持)。
这是使用 JSP 和 JSF 的限制。延迟表达式必须与控制标记一起使用(例如 outputText 。)
此问题已通过 Facelets View 技术得到解决;如果可能的话请考虑升级。
关于templates - 模板文本正文中不允许 JSF 和 EJB #{...},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8480187/