eclipse HTTP 状态 404 - 请求的资源 (/ProjectName/) 不可用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7798953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:36:15  来源:igfitidea点击:

HTTP Status 404 - The requested resource (/ProjectName/) is not available

eclipsejsptomcathttp-status-code-404welcome-file

提问by cProg

I'm getting the following error when running my Eclipse project on Tomcat server:

在 Tomcat 服务器上运行我的 Eclipse 项目时出现以下错误:

HTTP Status 404 - The requested resource (/ProjectName/) is not available.

HTTP 状态 404 - 请求的资源 (/ProjectName/) 不可用。

The URL in browser's address bar is http://localhost:8080/ProjectName/.

浏览器地址栏中的 URL 是http://localhost:8080/ProjectName/

I really don't know what is missing in my files. I have an Index.jspin the /WebContentfolder and my web.xmlcontains below entry:

我真的不知道我的文件中缺少什么。我Index.jsp/WebContent文件夹中有一个,我web.xml包含以下条目:

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

回答by BalusC

By default, when you open the project root folder as in http://localhost:8080/ProjectName/instead of a physical file as in http://localhost:8080/ProjectName/Index.jsp, then the server will lookup for a welcome file in web.xml. If none is found, then you'll get this 404 "Page not found" error.

默认情况下,当您打开项目根文件夹http://localhost:8080/ProjectName/而不是 中的物理文件时http://localhost:8080/ProjectName/Index.jsp,服务器将在web.xml. 如果没有找到,那么您将收到此 404“未找到页面”错误。

In your case, URLs and file names are case sensitive. You declared index.jspto be the welcome file, but you mentioned that you've an Index.jsp. Rename it to index.jspand then you'll be able to open the webapp's context root with the welcome file this way.

在您的情况下,URL 和文件名区分大小写。您声明index.jsp为欢迎文件,但您提到您有一个Index.jsp. 将其重命名为index.jsp,然后您就可以通过这种方式使用欢迎文件打开 web 应用程序的上下文根。

See also:

也可以看看:

回答by Utkal Santra

  1. In the Project Explorer right click on test (which is the name of your project, if I got it right)
  2. In the context menu choose Export->WAR file
  3. In the dialog window that pops up click the Browse... button to choose the destination folder for the deployment. This should be the web application folder(webs) of your Tomcat installation: /webapps where is the folder you have installed Tomcat in.
  4. Click Finish
  5. Now start your Tomcat.Assuming you have the index.html file in the WebContent folder of the test project in Eclipse, you should see the content of index.html in your browser when you open the URL. http://localhost:8080/projectApplication
  1. 在项目资源管理器中右键单击测试(这是您的项目名称,如果我没猜错的话)
  2. 在上下文菜单中选择导出-> WAR 文件
  3. 在弹出的对话窗口中,单击浏览...按钮选择部署的目标文件夹。这应该是 Tomcat 安装的 Web 应用程序文件夹(webs):/webapps 其中是您安装 Tomcat 的文件夹。
  4. 单击完成
  5. 现在启动你的 Tomcat。假设你在 Eclipse 中测试项目的 WebContent 文件夹中有 index.html 文件,当你打开 URL 时,你应该在浏览器中看到 index.html 的内容。 http://localhost:8080/projectApplication