【问题标题】:JSF and EJB #{...} not allowed in a template text body [duplicate]模板文本正文中不允许 JSF 和 EJB #{...} [重复]
【发布时间】:2011-12-12 20:08:35
【问题描述】:

我添加了 2 个托管 bean: ProductController 有 2 种方法:

ist<ProdusDTO> getList()
String update()

和 ProductDTO,用于实体 Product。

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 属性的方法?

谢谢。

【问题讨论】:

    标签: templates jsf datagrid ejb


    【解决方案1】:

    统一表达式语言 deferred expressions 仅允许在支持它们的自定义标记属性中使用(请参阅 JSP 2.1 了解 UEL 支持)。

    这是使用 JSP 和 JSF 的限制。延迟表达式必须与控制标签一起使用(例如 outputText。)

    此问题已通过 Facelets 视图技术得到解决;如果可能,请考虑升级。

    【讨论】:

    • 将#替换为$后,又报错:根据TLD,属性值为deferred-value或deferred-method,但指定值包含$-expression跨度>
    • @Emanuel - ${}#{} 表达式在不同时间使用不同的机制进行评估。您只能在 dataTable 中使用延迟表达式。
    • 他已经回答过了:例如使用&lt;h:outputText&gt; (或者干脆摆脱JSP并升级到它的后继Facelets)
    猜你喜欢
    • 2013-09-04
    • 1970-01-01
    • 2012-01-03
    • 2013-05-25
    • 1970-01-01
    • 2012-11-01
    • 1970-01-01
    相关资源
    最近更新 更多