在 Eclipse 上运行动态 Web 项目在 Tomcat 7 中出现 404 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13476957/
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-19 19:27:31  来源:igfitidea点击:

Running dynamic web projects on Eclipse brings up a 404 error in Tomcat 7

javaeclipsetomcatbuildhttp-status-code-404

提问by A_Elric

I'm not entirely sure why this happens.

我不完全确定为什么会发生这种情况。

Right now I'm able to build the project without running into any issues, and it deploys to the eclipse tomcat server that I have running

现在我能够在没有遇到任何问题的情况下构建项目,并且它部署到我正在运行的 eclipse tomcat 服务器

This is what my directory structure looks like.

这就是我的目录结构的样子。

So with that kept in mind, the index here is hera.jsp, which I have set in my web.xml file:

所以记住这一点,这里的索引是 hera.jsp,它是我在 web.xml 文件中设置的:

Web.xml file

Web.xml 文件

to make matters worse it seems like no matter what I try I always get this same error message:

更糟糕的是,无论我尝试什么,我总是收到相同的错误消息:

404

404

All I can think to include to make this more complete before posting is my build path and the server settings, so here's those as well.

在发布之前我能想到的所有内容是我的构建路径和服务器设置,所以这里也是这些。

ServerBuild path

服务器构建路径

采纳答案by Pawel Solarski

I had similar problem. First of all:

我有类似的问题。首先:

  1. Check if all the sources are copied to tomcat7 webapps, especially hera/WEB-INF/web.xml. If its not there, try to create dummy folder in your project, e.g. "hera/fix", and in your "project properties->deployment assembly" add this folder (as a result, "hera/fix -> /" mapping should be created). This worked for me when the eclipse plugin didn't want to copy web.xml.

  2. Check in "project properties->deployment assembly" if all needed libraries are there, if not, add them.

  3. Check why you have problems in src in your eclipse project, as that may interrupt or conflict the dynamic project deployment from eclipse.

  1. 检查是否所有源都复制到tomcat7 webapps,尤其是hera/WEB-INF/web.xml。如果它不存在,请尝试在您的项目中创建虚拟文件夹,例如“hera/fix”,并在您的“项目属性->部署程序集”中添加此文件夹(因此,“hera/fix -> /”映射应该创建)。当 eclipse 插件不想复制 web.xml 时,这对我有用。

  2. 如果所有需要的库都在,请检查“项目属性-> 部署程序集”,如果没有,请添加它们。

  3. 检查为什么您的 eclipse 项目中的 src 有问题,因为这可能会中断或冲突来自 eclipse 的动态项目部署。

Hope it helps.

希望能帮助到你。