部署基本Web应用程序时的HTTP 404

时间:2011-05-21 19:54:23

标签: eclipse jsf jsf-2 richfaces

我正在尝试通过互联网学习RichFaces的基础知识。我正在使用这个开发环境:

  1. Eclipse Helios Service Release 2(Build Id:20110218-0911)
  2. Glassfish开源版3.1 (插件安装在eclipse中)。
  3. RichFaces 4.0.0 Final(jar的补充 在我项目的WEB-INF / lib中)
  4. 但是,当我尝试使用Glassfish部署webapp时,我收到错误:HTTP 404 Not Found:

      

    请求的资源   (/JSFR4/test.jsf)不可用。

    我知道这是一个“找不到文件”的错误,但问题是我在任何应用程序中遇到的错误都在于我正在做什么,我不知道出了什么问题。在Glassfish管理控制台中部署了webapp,当我从这个控制台启动它时,我得到了同样的错误。

    server.log不记录任何错误。

    你能帮帮我吗?我做错了什么?

    以下是为项目生成的web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
      <description>Facelets StarterKit</description>
      <display-name>JSFR4</display-name>
      <context-param>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
      </context-param>
      <context-param>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>true</param-value>
      </context-param>
      <context-param>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>true</param-value>
      </context-param>
      <context-param>
        <param-name>facelets.REFRESH_PERIOD</param-name>
        <param-value>2</param-value>
      </context-param>
      <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
      </context-param>
      <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</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>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>/faces/*</url-pattern>
      </servlet-mapping>
    </web-app>
    

    这是为项目生成的faces-config:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
      <description>Facelets StarterKit</description>
      <display-name>JSFR4</display-name>
      <context-param>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
      </context-param>
      <context-param>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>true</param-value>
      </context-param>
      <context-param>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>true</param-value>
      </context-param>
      <context-param>
        <param-name>facelets.REFRESH_PERIOD</param-name>
        <param-value>2</param-value>
      </context-param>
      <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
      </context-param>
      <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</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>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>/faces/*</url-pattern>
      </servlet-mapping>
    </web-app>
    

    而这是我的xhtml文件(非常简单)

    <f:view>
        <h:head></h:head>
        <h:body>
            <rich:panel header="RichFaces Example">
                <ul>
                    <li>This is an Example of Richfaces</li>
                    <li>A JSF Library</li>
                </ul>
            </rich:panel>
        </h:body>
    </f:view>
    

    感谢Everyone

1 个答案:

答案 0 :(得分:0)

您的.xhtml文件通常应该位于上下文的根目录中。类似的东西:

webapps/
    yourapp/
        WEB-INF/
        test.xhtml
        foo.xhtml