我爲我的JSF應用程序實現了HttpSessionListener。無法使用[1]參數找到方法[屬性]
我有一個List<HttpSession>
所有活動會話的對象到我的應用程序。在每個SessionCreated Event上,我將實際的HttpSession
添加到List
。在登錄時,我將一些屬性添加到活動會話中,並替換List
中修改的會話。到目前爲止,這很好,它工作。但是現在我創建了一個PrimeFaces數據表來顯示哪個Session是一個未使用的Session。這意味着哪個會話沒有登錄屬性。 Login屬性是一個簡單的String對象。
這裏是DataTable的實現:
<p:dataTable var="sessions" value="#{applicationListener.sessions}" paginator="false" id="dt_sessions">
<f:facet name="header">
Sessions
</f:facet>
<p:column headerText="ID" style="font-size: 12px; text-align: center" >
#{sessions.id}
</p:column>
<p:column headerText="Name" style="font-size: 12px; text-align: center" >
#{sessions.attribute(login)}
</p:column>
</p:dataTable>
的Tomcat拋出一個HTTP 500堆棧跟蹤:
Feb 6, 2013 2:00:50 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [] threw exception [/rmlcon.xhtml: Unable to find method [attribute] with [1] parameters] with root cause
javax.el.ELException: /rmlcon.xhtml: Unable to find method [attribute] with [1] parameters
at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:88)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularCell(DataTableRenderer.java:741)
at org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:693)
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:601)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:220)
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:192)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:74)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
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:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
我真的不明白爲什麼它被拋出。請有人能解釋我的錯誤嗎?
謝謝。
謝謝。請注意:並非每次NetBeans的自動完成功能都是構建表達式的最佳方式。我遵循你的建議,並改變了我的代碼。 – commandcraxx
任何想法,爲什麼我需要這樣的引號'#{sessions.getAttribute(「login」)}'?否則,收到bean的參數是空字符串。使用Tomcat7。 –
@Panu:在OP的情況下,'login'是一個包含實際屬性鍵的變量。你顯然沒有這樣的變量,它實際上是屬性鍵本身。然後你應該通過引用它來對屬性鍵進行「硬編碼」。順便說一下,通常使用單引號,因爲它在HTML/JSF標籤屬性內工作得更好,而這些屬性本身通常用雙引號括起來。 – BalusC