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

标签 java tomcat http-status-code-404

我按照 o7planning 的教程进行操作,但在第 6 步卡住了:

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

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

enter image description here 但是 Tomcat 欢迎页面显示正常。

Tomcat welcome page

到目前为止我尝试过的解决方案(但它们不起作用):

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.

最佳答案

问题已解决,我没有添加 index.htmlweb.xml

中指出了这一点

enter image description here

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

如果

中还有另一个web.xml

src/main/webapp/WEB-INF

那么你可能需要添加另一个索引(这次是index.jsp)到

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

关于java - Tomcat 404 错误 : The origin server did not find a current representation for the target resource or is not willing to disclose that one exists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43186315/

相关文章:

Java 线程死锁示例

java - 将 ArrayList<Double> 传递给另一个类

java - 打印tomcat版本和路径

java - 多个 MongoDB 连接到多个 mongo 路由器 (mongos.exe)

javascript - 链接 Bootstrap 的本地副本

java - 在 Tomcat 上成功部署我的项目,但无法请求。显示 404

java - RxJava reduce() 在并行化时会不安全吗?

java - 我可以更改 Java 中变量的声明类型吗?

tomcat - 在 Spring Boot 嵌入式 Tomcat 中配置 maxKeepAliveRequests

PHP 中的 404 脚本到 301?