0

我创建了一个非常简单的 RichFaces Page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
    <h:outputStylesheet>
        .cols {
        vertical-align: top;
        }
    </h:outputStylesheet>
    <h:form id="form">
        <h:panelGrid columns="2" columnClasses="cols,cols" width="400">
            <rich:panelMenu style="width:200px" itemMode="ajax" groupMode="ajax" groupExpandedLeftIcon="triangleUp"
                groupCollapsedLeftIcon="triangleDown" topGroupExpandedRightIcon="chevronUp"
                topGroupCollapsedRightIcon="chevronDown" itemLeftIcon="disc" itemChangeListener="#{panelMenuBean.updateCurrent}">
                <rich:panelMenuGroup label="Group 1">
                    <rich:panelMenuItem label="Item 1.1" name="Item_1_1" />
                    <rich:panelMenuItem label="Item 1.2" name="Item_1_2" />
                    <rich:panelMenuItem label="Item 1.3" name="Item_1_3" />
                </rich:panelMenuGroup>
                <rich:panelMenuGroup label="Group 2">
                    <rich:panelMenuItem label="Item 2.1" name="Item_2_1" />
                    <rich:panelMenuItem label="Item 2.2" name="Item_2_2" />
                    <rich:panelMenuItem label="Item 2.3" name="Item_2_3" />
                    <rich:panelMenuGroup label="Group 2.4">
                        <rich:panelMenuItem label="Item 2.4.1" name="Item_2_4_1" />
                        <rich:panelMenuItem label="Item 2.4.2" name="Item_2_4_2" />
                        <rich:panelMenuItem label="Item 2.4.3" name="Item_2_4_3" />
                    </rich:panelMenuGroup>
                    <rich:panelMenuItem label="Item 2.5" name="Item_2_5" />
                </rich:panelMenuGroup>
                <rich:panelMenuGroup label="Group 3">
                    <rich:panelMenuItem label="Item 3.1" name="Item_3_1" />
                    <rich:panelMenuItem label="Item 3.2" name="Item_3_2" />
                    <rich:panelMenuItem label="Item 3.3" name="Item_3_3" />
                </rich:panelMenuGroup>
            </rich:panelMenu>
        </h:panelGrid>
    </h:form>
</ui:composition>

我的面孔-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">

</faces-config>

我的 web.xml 读作

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  <display-name>
    trinity
</display-name>
  <description>
    C'mon, you know what goes into a description, don't you?
</description>

  <!-- Plugging the "Blue Sky" skin into the project -->
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/jsf/*</url-pattern>
</servlet-mapping>
<login-config>
    <auth-method>BASIC</auth-method>
</login-config>
</web-app>

但是当我尝试访问该页面时,我收到一条错误消息

java.lang.NullPointerException
    com.sun.faces.context.flash.ELFlash.doLastPhaseActions(ELFlash.java:607)
    com.sun.faces.context.ExternalContextImpl.responseFlushBuffer(ExternalContextImpl.java:857)
    com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:155)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

我有所有必需的库。我是 JSF 2 和 RichFaces 的新手。有什么想法我哪里出错了吗?感谢您提前提供任何帮助。

4

1 回答 1

1

从堆栈跟踪:

com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:155)

因此,当您使用 Facelets 语法时,它将视图构建为 JSP 而不是 Facelets。

确保您的页面文件扩展名正确。应该是.xhtml,不是.jsp

于 2012-06-11T14:14:18.060 回答