Java Tomcat 404 错误:源服务器没有找到目标资源的当前表示或不愿意透露一个存在

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

Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

javatomcathttp-status-code-404

提问by Lê Quang B?o

I was following the tutorial on o7planningand got stuck at step 6:

我正在学习 o7planning教程,卡在了第 6 步:

http://o7planning.org/en/10169/java-servlet-tutorial

http://o7planning.org/en/10169/java-servlet-tutorial

It's just a simple project that show HelloWorldbut for some reason I keep getting 404error. Detail:

这只是一个显示HelloWorld的简单项目,但由于某种原因,我不断收到404错误消息。细节:

enter image description hereHowever the Tomcat welcome page showing properly.

在此处输入图片说明但是 Tomcat 欢迎页面显示正确。

Tomcat welcome page

Tomcat 欢迎页面

Here solutions that I've tried so far (and they are NOT working):

这是我迄今为止尝试过的解决方案(它们不起作用):

Right-click project -> properties -> Project Facets -> Runtimes -> checked "Apache Tomcat v9.0" -> Apply -> finish.

Server tab -> Right-click "Tomcat v9.0..." -> properties -> switch location -> Choose "Use tomcat installation" on "Server locations" panel.

右键单击项目-> 属性-> 项目构面-> 运行时-> 选中“Apache Tomcat v9.0”-> 应用-> 完成。

服务器选项卡 -> 右键单击​​“Tomcat v9.0...” -> 属性 -> 切换位置 -> 在“服务器位置”面板上选择“使用 tomcat 安装”。

采纳答案by Lê Quang B?o

Problem solved, I've not added the index.html. Which is point out in the web.xml

问题解决了,我没有添加index.html。这是在web.xml 中指出的

enter image description here

在此处输入图片说明

Note:a project may have more than one web.xmlfile.

注意:一个项目可能有多个web.xml文件。

if there are another web.xmlin

如果有其他的web.xml

src/main/webapp/WEB-INF

src/main/webapp/WEB-INF

Then you might need to add another index (this time index.jsp) to

然后您可能需要添加另一个索引(这次index.jsp)到

src/main/webapp/WEB-INF/pages/

src/main/webapp/WEB-INF/pages/

回答by Michael Joshua Ramos

Hope this helps. From eclipse, you right click the project -> Run As -> Run on Server and then it worked for me. I used Eclipse Jee Neon and Apache Tomcat 9.0. :)

希望这可以帮助。在 Eclipse 中,您右键单击项目 -> 运行方式 -> 在服务器上运行,然后它对我有用。我使用了 Eclipse Jee Neon 和 Apache Tomcat 9.0。:)

I just removed the head portion in index.html file and it worked fine.This is the head tag in html file

我刚刚删除了 index.html 文件中的头部部分,它工作正常。这是html文件中的head标签