Java Eclipse Neon w/Tomcat 9(新Servlet)HTTP状态404–;找不到

Java Eclipse Neon w/Tomcat 9(新Servlet)HTTP状态404–;找不到,java,eclipse,tomcat,servlets,Java,Eclipse,Tomcat,Servlets,我是新来的,在Eclipse中跟踪一个HelloWorld项目,该项目刚刚添加了一个servlet(我正在使用Eclipse Neon w/Tomcat 9)。当我在服务器上运行时,会出现以下错误。连接到index.html没有任何问题,只有servlet!下面是屏幕截图,请告诉我是否需要提供更多信息-Thx 404Error[1] servlet[2] webxml[3] indexhtml[4] 很可能web容器找不到您的servlet web容器是与Java servlet交互的web服

我是新来的,在Eclipse中跟踪一个HelloWorld项目,该项目刚刚添加了一个servlet(我正在使用Eclipse Neon w/Tomcat 9)。当我在服务器上运行时,会出现以下错误。连接到index.html没有任何问题,只有servlet!下面是屏幕截图,请告诉我是否需要提供更多信息-Thx

404Error[1]
servlet[2]
webxml[3]
indexhtml[4]

很可能web容器找不到您的servlet

web容器是与Java servlet交互的web服务器的组件

  • web容器负责管理servlet的生命周期
  • 将URL映射到特定servlet

  • 确保URL请求者具有正确的访问权限

您可以在web.xml中配置servlet

<servlet>
  <servlet-name>servletName</servlet-name>
  <servlet-class>packageName.servletName</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>servletName</servlet-name>
  <url-pattern>/yourServletUrl</url-pattern>
</servlet-mapping>
它更容易阅读

您的url应该是

localhost:8080/YourProjectName/YourServletUrl
我还记得EclipseNeon不能很好地与JavaEE配合使用,请尝试下载其他版本


在google中键入download Eclipse for JavaEE developers,然后重试。

生成404的URL是什么?发布
web.xml
localhost:8080/YourProjectName/YourServletUrl