【问题标题】:404 when setting up Eclipse Dynamic Web Application设置 Eclipse 动态 Web 应用程序时出现 404
【发布时间】:2015-01-15 03:25:04
【问题描述】:

这是我第一次尝试自行设置 Web 应用程序项目,但由于某种原因,我什至无法让它与 hello world 设置一起使用。我将所有内容都设置为默认值,选择用于编译的 JDK1.8 和一个带有 index.html 页面的 Tomcat7 服务器,其中只有文本。将项目添加到服务器后,我应该能够右键单击项目并在服务器上运行,但即使使用这个简单的设置,我仍然会收到 404。我错过了什么?

Web.xml 欢迎列表:

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>

【问题讨论】:

  • 您访问的是哪个网址?
  • localhost:8080/[Project Name],当你运行时 Eclipse 会自动命中它。在服务器上运行。
  • 提供项目结构的详细信息。

标签: java eclipse http-status-code-404 tomcat7


【解决方案1】:

您不能直接访问 WEB-INF 文件夹下的文件。容器会在 WEB-INF/classes 中查找类,WEB-INF 下的 jsp 文件可以被其他 JSP 包含,但是任何浏览器在下面请求资源都会得到 404 响应。

您应该将 index.xhtml 路径从 webapp/WEB-INF/index.html 更改为 webapp/index.html 以对应您的 web.xml

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-02
    • 2021-06-11
    • 2012-05-28
    • 2015-12-10
    • 1970-01-01
    • 1970-01-01
    • 2016-06-11
    • 1970-01-01
    相关资源
    最近更新 更多