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 Getdata.java and Jdbcutil.java 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>xxx.xxx</servlet-class>java Request-forwarding classes in web development
, the Getdata.java 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!
Statement:
About the Knowledge point 1 and Example 1 is from http://www.cnblogs.com/hxsyl/p/3435412.html view
Zhang BongfeiSource:http://www.cnblogs.com/hxsyl/ thanks to the predecessor!!!!! Knowledge point 2 from: http://zhidao.baidu.com/link?url=UKe5wRdw1YHf_BynVljjZDEhF1rVVcwwP5_jdAi-OQXh0DjBdZCrHIZN_ Ybkktuoxcuit3rly281ll4l70fjlaseems
The servlet project could not find a Java file (due to a bug caused by copying the code)