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

发布于 2024-11-08 17:46:23 字数 4897 浏览 0 评论 0原文

我正在尝试通过互联网上的基本教程来学习 RichFaces 的基础知识。我正在使用此开发环境:

  1. Eclipse Helios Service Release 2(内部版本号:20110218-0911)
  2. Glassfish Open Source Edition 3.1 (在 eclipse 中安装插件)。
  3. RichFaces 4.0.0 Final(已添加 jar 在我的项目的 WEB-INF/lib 中)

但是,当我尝试使用 Glassfish 部署 web 应用程序时,我收到错误:HTTP 404 Not Found:

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

我知道这是一个“找不到文件”错误,但是问题是我在我正在执行的任何应用程序中都会遇到相同的错误,而且我不知道出了什么问题。在 Glassfish 管理控制台中部署了 Web 应用程序,当我从此控制台启动它时,我收到了相同的错误。

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>

感谢大家

I'm trying to learn the basics of RichFaces with basic tutorials over the internet. I'm Using this Development Environment:

  1. Eclipse Helios Service Release 2 (Build Id: 20110218-0911)
  2. Glassfish Open Source Edition 3.1
    (Plugin Installed in eclipse).
  3. RichFaces 4.0.0 Final (jar's added
    in WEB-INF/lib in my project)

But, while i'm trying to deploy the webapp with Glassfish, i get the error: HTTP 404 Not Found:

The requested resource
(/JSFR4/test.jsf) is not available.

I know it's an "File Not Found" error, but, the problem is that i'm getting the same error in any application what i'm doing, and i don't know what is wrong. In the Glassfish Administration Console the webapp is deployed, and, when i'm launching it from this console, i'm getting the same error.

The server.log doesn't log any error.

Can You help me? What i'm doing wrong?

Here is the web.xml generated for the project:

<?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>

This is the faces-config generated for the project:

<?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>

And This, is my xhtml file (Very simple)

<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>

Thanks to Everyone

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

‖放下 2024-11-15 17:46:23

您的 .xhtml 文件通常应位于上下文的根目录中。像这样的东西:

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

Your .xhtml files should normally go in the root of the context. Something like:

webapps/
    yourapp/
        WEB-INF/
        test.xhtml
        foo.xhtml
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文