Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to solve HTTP status 404 error when using @WebServlet annotation?

User_QGDP7Oct 1 2021

Hi everyone,I am a beginner of Servlet.
I want to replace web.xml with annotation @WebServlet to specify the url.Here's my servlet class annotation.
@WebServlet(urlPatterns="/demo1")
But I got a 404 NotFound error when I ran the project and entered "localhost/demo1"(port is set to 80) in Browser's url input field.I have checked the configuration in web.xml,in which the version is 4.0 and metadata-complete is false.
I have searched on net for a long time.But no use.Please help or try to give some ideas about how to achieve this.
Thanks in advance.

Comments
Post Details
Added on Oct 1 2021
0 comments
1,331 views