h:dataTable throws java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/sql/Result
h:dataTable throws java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/sql/Result
这是我的 table:
<h:dataTable value="#{registerS.students}" var="registerS.student">
<h:column>
<f:facet name="header">Name</f:facet>
#{registerS.student.userName}
</h:column>
<h:column>
<f:facet name="header">Surname</f:facet>
#{registerS.student.userSurname}
</h:column>
<h:column>
<f:facet name="header">email</f:facet>
#{registerS.student.email}
</h:column>
<h:column>
<f:facet name="header">password</f:facet>
#{registerS.student.password}
</h:column>
<h:column>
<f:facet name="header">classCode</f:facet>
#{registerS.student.classCode}
</h:column>
</h:dataTable>
用这个页面打开一个页面时,我得到这个异常:
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/sql/Result
javax.faces.component.UIData.getDataModel(UIData.java:1822)
javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484)
javax.faces.component.UIData.setRowIndex(UIData.java:473)
com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:82)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:869)
javax.faces.component.UIData.encodeBegin(UIData.java:1133)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854)
javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
这是怎么引起的,我该如何解决?
JSF has a dependency on JSTL for several things. One of them is inspecting which DataModel
should be used behind <h:dataTable value>
. It also supports JSTL <sql:query var="result">
(十年来一直不鼓励,但除此之外)。
显然你是 运行 准系统 servletcontainer 而不是真正的 Java EE 服务器。堆栈跟踪提示它是 Tomcat. It ships only Servlets, JSP, EL and WS out the box. It doesn't ship all other Java EE stuff out the box such as JSF, JSTL, CDI, EJB, JPA, JTA, JMS, etc..etc.. You have to install it manually (or just move to a real Java EE server such as TomEE or WildFly).
您可以在 our JSF wiki page 的 "Installing JSF" 部分找到正确的 JSTL JAR 和正确的 Maven 依赖关系的 link。
这是我的 table:
<h:dataTable value="#{registerS.students}" var="registerS.student">
<h:column>
<f:facet name="header">Name</f:facet>
#{registerS.student.userName}
</h:column>
<h:column>
<f:facet name="header">Surname</f:facet>
#{registerS.student.userSurname}
</h:column>
<h:column>
<f:facet name="header">email</f:facet>
#{registerS.student.email}
</h:column>
<h:column>
<f:facet name="header">password</f:facet>
#{registerS.student.password}
</h:column>
<h:column>
<f:facet name="header">classCode</f:facet>
#{registerS.student.classCode}
</h:column>
</h:dataTable>
用这个页面打开一个页面时,我得到这个异常:
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/sql/Result
javax.faces.component.UIData.getDataModel(UIData.java:1822)
javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484)
javax.faces.component.UIData.setRowIndex(UIData.java:473)
com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:82)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:869)
javax.faces.component.UIData.encodeBegin(UIData.java:1133)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854)
javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
这是怎么引起的,我该如何解决?
JSF has a dependency on JSTL for several things. One of them is inspecting which DataModel
should be used behind <h:dataTable value>
. It also supports JSTL <sql:query var="result">
(十年来一直不鼓励,但除此之外)。
显然你是 运行 准系统 servletcontainer 而不是真正的 Java EE 服务器。堆栈跟踪提示它是 Tomcat. It ships only Servlets, JSP, EL and WS out the box. It doesn't ship all other Java EE stuff out the box such as JSF, JSTL, CDI, EJB, JPA, JTA, JMS, etc..etc.. You have to install it manually (or just move to a real Java EE server such as TomEE or WildFly).
您可以在 our JSF wiki page 的 "Installing JSF" 部分找到正确的 JSTL JAR 和正确的 Maven 依赖关系的 link。