今天在调试jsf ,在调试jsf 的时候我在使用表单的时候,使用了jsf的组件datatable,但是在显示的时候确实老是出现同样的一个问题,报错如下显示:
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Expression: '#{name.last}'
javax.faces.webapp.FacesServlet.service(FacesServlet.java:125)
root cause
javax.faces.FacesException: Expression: '#{name.last}'
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:411)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:280)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:300)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:110)
好像是我没有绑定name中的last值,但是我有的,下面是我的代码的一部分,请大侠们指教:)
index.jsp的 代码
- <html>
- <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
- <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
- <f:view>
- <HEAD>
- <title>
- <f:loadBundle basename="com.corejsf.messages" var="msgs"/>
- <h:outputText value="#{msgs.windowTitle}"/>
- <title>
- <HEAD>
- <body>
- <h:form>
- <h:dataTable value="#{tableDate.names}" var="names">
- <h:column>
- <f:facet name="header">
- <h:outputText value="#{msgs.editColumn}" style="font-weight:bold"/>
- <f:facet>
- <h:selectBooleanCheckbox value="#{tableDate.editable}" onclick="submit()"/>
- <h:column>
- <h:column>
-
- <f:facet name="header">
- <h:outputText value="#{msgs.lastnameColumn}" style="font-weight:bold"/>
- <f:facet>
- <h:inputText value="#{name.last}" rendered="#{tableDate.editable}" size="10"/>
- <h:outputText value="#{name.last}" rendered="#{not tableDate.editable}"/>
-
- h:column>
-
- <h:column>
- <f:facet name="header">
- <h:outputText value="#{msgs.firstnameColumn}" style="font-weight:bold"/>
- <f:facet>
- <h:inputText value="#{name.first}" rendered='#{tableDate.editable}' size="10"/>
- <h:outputText value="#{name.first}" rendered="#{not tableDate.editable}"/>
-
- </h:column>
- </h:dataTable>
- <p>
- <h:commandButton value="#{msgs.sveChangesButtonText}"/>
- </h:form>
- </f:view>
-
- </html>
faces-config.xml 代码
- <managed-bean>
- <managed-bean-name>tableDatemanaged-bean-name>
- <managed-bean-class>com.jsf.TableDatamanaged-bean-class>
- <managed-bean-scope>sessionmanaged-bean-scope>
-
- </managed-bean>
TableData.java 代码
- package com.jsf;
-
- public class TableData {
- private static final Name[] names=new Name[]{
-
- new Name("李","四"),
- new Name("张","三"),
- new Name("王","五"),
- new Name("柳","六"),
- new Name("赵","七"),
- };
- public Name[] getNames(){return names;}
-
- private boolean editable=true;
- public boolean isEditable() {
- return editable;
- }
- public void setEditable(boolean editable) {
- this.editable = editable;
- }
- }
还有就是name.java的代码就不列出了,无非就是一些属性的声明之类的东东:)