2011-12-08 17 views
2

我有一個JSF組件index.jsp JSP文件:java.lang.IllegalStateException:組件javax.faces.component.UIViewRoot預計不會式

<body> 
     <h:form prependId="false"> 
       <h:panelGrid id="panelLogin" columnClasses="colLabel,colValor" columns="2"> 
        <f:facet name="header"> 
         <h:outputText value="Panel de Log-In" /> 
        </f:facet> 

        <h:outputLabel value="Usuario" for="txtNombre" /> 
        <h:inputText id="txtNombre" value="#{manejadorLogin.usuario}" /> 
        <h:outputLabel value="Password" for="txtPassword" /> 
        <h:inputText id="txtPassword" value="#{manejadorLogin.password}" /> 

        <f:facet name="footer"> 
         <h:panelGrid columns="2"> 
          <h:commandButton value="Login" action="#{manejadorLogin.loginUsuario}" /> 
          <h:commandButton value="Limpiar" type="reset" />            
         </h:panelGrid> 
        </f:facet> 
       </h:panelGrid> 
     </h:form> 
    </body> 

當我按下「登錄」按鈕,我得到這個錯誤:

An Error Occurred: java.lang.IllegalStateException: Component [email protected] not expected type. Expected: javax.faces.component.UIOutput. Perhaps you're missing a tag?

這是怎麼回事,我該如何解決呢?

回答

5

An Error Occurred: java.lang.IllegalStateException: Component [email protected] not expected type. Expected: javax.faces.component.UIOutput. Perhaps you're missing a tag?

該操作導航到的JSP文件中缺少<f:view>標記。如果您使用舊版JSP作爲視圖技術而不是其後續版本的Facelets,那麼您需要確保所有JSF組件都包含在父代<f:view>標記內(這是由UIViewRoot組件代表的幕後)。

你需要改變你的JSP文件,以符合下列基本模板(注意<f:view>):

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> 
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> 
<!DOCTYPE html> 
<f:view> 
    <html lang="en"> 
     <head> 
      <title>JSP page with JSF components</title> 
     </head> 
     <body> 
      <h:outputText value="JSF components here." /> 
     </body> 
    </html> 
</f:view> 
+0

太感謝你了;!現在我在另一臺電腦上,但明天當我醒來時我會嘗試它!...再次感謝您的時間...... – Agustin

相關問題