简体   繁体   English

基本的Web应用程序,但出现404错误Tomcat / Eclipse

[英]Basic web application but getting 404 error Tomcat/Eclipse

I have a simple dynamic web application in eclipse as shown in below image: 我在Eclipse中有一个简单的动态Web应用程序,如下图所示:

在此处输入图片说明

and my web.xml is as below (provided only relavent sections to reduce complexity): 我的web.xml如下所示(仅提供了relavent部分以降低复杂性):

<web-app ... 
<display-name>DemoRest</display-name>
<servlet>
   <servlet-name>JerseyWebService</servlet-name>
   <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>JerseyWebService</servlet-name>
  <url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
  <welcome-file>index.html</welcome-file>
</welcome-file-list>

But when I run I am getting "404 error" as shown below: 但是当我运行时,出现“ 404错误”,如下所示: 在此处输入图片说明

As you can see my Context-Path matches with my folder and actual files are there in correct location, still I am not able to run the application. 如您所见,我的上下文路径与文件夹匹配,并且实际文件位于正确的位置,但是我仍然无法运行该应用程序。 I tried of cleaning, rebuilding, restarting of eclipse but still no luck. 我试图清理,重建,重新开始日食,但还是没有运气。 Can anyone help me, why this happens with tomcat? 谁能帮我,为什么tomcat会发生这种情况?

<servlet-mapping>
   <servlet-name>JerseyWebService</servlet-name>
   <url-pattern>/*</url-pattern>
</servlet-mapping>

This is not available because the url 这不可用,因为网址

 http://localhost:8080/DemoRest/NewFile.jsp

will be intercepted by JerseyWebService, which I guess is not an intended action. 将被JerseyWebService拦截,我想这不是预期的操作。

Why not host rest services on path like: 为什么不在以下路径上托管休息服务:

<servlet-mapping>
   <servlet-name>JerseyWebService</servlet-name>
   <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM