1

对于一个简单的 jsf 2.0 和 Tomcat 7 应用程序,我收到以下错误:

转换错误 java.lang.ClassCastException: javax.faces.component.UIViewRoot 不能转换为 org.portletfaces.bridge.component.PortletNamingContainerUIViewRoot

  Aug 24, 2012 11:55:40 AM com.sun.faces.application.view.FaceletViewHandlingStrategy       handleRenderException
 SEVERE: Error Rendering View[/hello.xhtml]
 java.lang.ClassCastException: javax.faces.component.UIViewRoot cannot be cast to   org.portletfaces.bridge.component.PortletNamingContainerUIViewRoot
at   org.portletfaces.bridge.renderkit.html_basic.HeadRenderer.encodeBegin(HeadRenderer.java:62)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:823)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1611)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
at   com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrateg       y.java:380)

hello.xhtml 如下:

      <?xml version="1.0" encoding="UTF-8"?>
   <!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:f="http://java.sun.com/jsf/core"      
     xmlns:h="http://java.sun.com/jsf/html">

<h:body>

    <h:form>
       <h:commandButton value="Welcome Me" action="welcome"></h:commandButton>
    </h:form>
</h:body>
  </html>
4

1 回答 1

0

我也有同样的问题。但是一旦 h:head 或 h:body 被删除,页面加载正常,除了需要 h:head 的 javascripts 和 css。这些将不会被加载。

于 2014-09-17T21:12:39.777 回答