0

I am using jsf 2 along with tomcat 6, and I am trying to execute this code which is in a .xhtml page that I have:

    <h:dataTable value="${LogModel.getLogList()}" var="c"
            styleClass="order-table"
            headerClass="order-table-header"
            rowClasses="order-table-odd-row,order-table-even-row"
        >

I do have the class logmodel and the method getLogList(), however I get this error when i launch the page:

/testLog.xhtml @20,8 value="${LogModel.getLogList()}" Failed to parse the expression [${LogModel.getLogList()}]

Here is the complete log of the problem:

javax.faces.view.facelets.TagAttributeException: /testLog.xhtml @20,8 value="${LogModel.getLogList()}" Failed to parse the expression [${LogModel.getLogList()}]
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:401)
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:351)
at com.sun.faces.facelets.tag.jsf.ComponentRule$ValueExpressionMetadata.applyMetadata(ComponentRule.java:107)
at com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:81)
at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:129)
at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:102)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.doNewComponentActions(ComponentTagHandlerDelegateImpl.java:398)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:159)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:769)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.el.ELException: Failed to parse the expression [${LogModel.getLogList()}]
    at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:146)
    at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:172)
    at org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:216)
    at org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
    at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:385)
    ... 34 more
Caused by: org.apache.el.parser.ParseException: Encountered " "(" "( "" at line 1, column 22.
Was expecting one of:
    "}" ...
    "." ...
    "[" ...
    ">" ...
    "gt" ...
    "<" ...
    "lt" ...
    ">=" ...
    "ge" ...
    "<=" ...
    "le" ...
    "==" ...
    "eq" ...
"!=" ...
"ne" ...
"&&" ...
"and" ...
"||" ...
"or" ...
"*" ...
"+" ...
"-" ...
"/" ...
"div" ...
"%" ...
"mod" ...

at org.apache.el.parser.ELParser.generateParseException(ELParser.java:2142)
at org.apache.el.parser.ELParser.jj_consume_token(ELParser.java:2024)
at org.apache.el.parser.ELParser.DynamicExpression(ELParser.java:147)
at org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:43)
at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:114)
... 38 more

Your kind help would be greatly appreciated! Thank you

4

2 回答 2

4

EL 语法${LogModel.getLogList()}自 EL 2.2 起才受支持,它与 Servlet 3.0 一起使用。但是您使用的是旧的 Tomcat 6 服务器,它是一个 Servlet 2.5 容器,它意味着 EL 2.1。然后您需要使用正常的 EL 2.1 语法。

${LogModel.logList}

如果您真的坚持使用调用操作方法的新 EL 2.2 语法,那么您始终可以按照以下答案中所述安装 JBoss EL:Invoke direct methods or methods with arguments/variables/parameters in EL然而,这对于简单的 getter 方法,然后可以通过更简单的 EL 语法访问。

初学者的一个主要误解是他们认为这种新的 EL 2.2 语法是特定于 JSF 2.0 的。但这实际上是不正确的。造成这种混淆的原因是 EL 2.2 和 JSF 2.0 都是 Java EE 6 的一部分,但 JSF 2.0 本身向后兼容 Java EE 5(Servlet 2.5、EL 2.1 等)。

于 2012-06-12T04:49:55.373 回答
1

1) 是#,不是$

2) 删除括号()get. 您使用的是属性,而不是方法(即使您需要在类中定义它们)。

3) 最有可能的是,bean 名称也必须以小写字母开头(您正在访问一个对象,而不是一个类)。

value="#{logModel.logList}" 
于 2012-06-11T22:28:11.550 回答