0

伙计们,出于某种原因,EL 没有告诉属性的动作。我有这个页面 test.xhtml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html   xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core">

<body>

<form action="#{TestBean.test}">
    <p>#{TestBean.status}</p>
    <input type="submit" value="Test Again"/>
</form>

</body>

</html>

TestBean.status 是一个字符串属性(有一个 getStatus 方法),TestBean.test 是一个返回“成功”的方法。

每次我调用该页面时,我都会收到此异常:

ERROR [STDERR] 05/08/2009 17:41:07 com.sun.facelets.FaceletViewHandler handleRenderException
SEVERE: Error Rendering View[/etc/test/test.xhtml]
javax.el.ELException: /etc/test/test.xhtml: Bean: test.TestBean, property: test
    at com.sun.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:53)
    at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
    at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232)
    at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
    at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
    at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
    at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Unknown Source)

也许这是一个长镜头,我可以更好地描述我的环境。但乍一看,有什么提示吗?

tks

4

2 回答 2

0

我认为问题在于忘记了 jsfc 属性。

它应该是:

<form **jsfc="h:form"** action="#{TestCaseBean.test}">

tks。

于 2009-08-05T22:01:15.560 回答
0

据我所知,EL 没有调用任意方法的语法。您使用的语法在应用于除 、 或数组以外的任何内容时MapList将查找与名称对应的属性 getter;点是 . 的语法糖TestBean["test"]

虽然可以为 EL 定义自定义函数作为 JSP 标记库的一部分,但它们必须由静态方法实现。有关如何执行此操作的更多信息,请参阅本教程。

但是,此功能目前在 JSR 管道中。

于 2009-08-05T21:02:18.377 回答