简体   繁体   English

Eclipse Maven Web App-HTTP状态500和404错误

[英]Eclipse maven web app - HTTP Status 500 and 404 errors

Although I am proficient in Java, I am completely new to developing web apps with maven and I am struggling to get started by creating a simple HelloWorld servlet app - I'm using Eclipse Mars and Tomcat 8. 尽管我精通Java,但是我对使用Maven开发Web应用程序是完全陌生的,并且我正努力通过创建一个简单的HelloWorld servlet应用程序来上手-我正在使用Eclipse Mars和Tomcat 8。

I have added a simple servlet which should print out "hello world" but when I attempt to run the servlet by using the url-pattern (so http://localhost:8080/MyApp/HelloWorld ) I get a 404 error. 我添加了一个简单的servlet,它应该打印出“ hello world”,但是当我尝试使用url-pattern(因此http://localhost:8080/MyApp/HelloWorld )运行servlet时,出现404错误。

When I ran the app for the very first time I got a 500 error stating that my servlet class could not be found but when I refreshed the page it changed to 404. Now I only get a 404 error. 当我第一次运行该应用程序时,出现500错误,指出找不到我的servlet类,但是当我刷新页面时,它更改为404。现在我仅收到404错误。 I have already tried the following but no joy - TOMCAT - HTTP Status 404 . 我已经尝试了以下操作,但没有任何乐趣-TOMCAT-HTTP Status 404

Any help would be much appreciated. 任何帮助将非常感激。

Servlet类和web.xml

You have your java sources located in src/main/resources which is not the right place for this. 您的Java源位于src/main/resources ,这不是正确的位置。 Please create a directory src/main/java and put them there. 请创建目录src/main/java并将其放置在该目录中。 This should remedy your problem. 这应该可以解决您的问题。

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

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