The servlet project could not find a Java file (due to a bug caused by copying the code)

Source: Internet
Author: User

In fact, this bug is very simple, actually because of the path configuration problem, but also because I copied the code caused by (good kids do not learn!) )

Here's the case: there's no problem with the Java file, but there was a bug when starting the project:

Then when I put the and files into the default package:

Connected to the server ....

Well, I think this is my Java file path configuration is wrong, so Baidu to find the answer

Find several important points of knowledge:

"/" in 1.<url-pattern>/xx</url-pattern> represents the root path of the current web App

2.<servlet-class></servlet-class>java Request-forwarding classes in web development

, the file that is used for the information to the database and displayed in this project

And so on, I see people write like this:

Example 1:<servlet-class>net.test.testservlet</servlet-class>

It's like a package path to a Java file (I forgot what the jargon says, if anyone knows please tell me in the comments section, thank you)

Try after you know the cause (the change is indicated by a red circle):

Run successfully:

Reflection: code can never copy (I feel stupid), to quickly add Java Web, SQL statements, MAVEN related knowledge!


About the Knowledge point 1 and Example 1 is from view

Zhang BongfeiSource: thanks to the predecessor!!!!!   Knowledge point 2 from: Ybkktuoxcuit3rly281ll4l70fjlaseems 

The servlet project could not find a Java file (due to a bug caused by copying the code)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.