After configuring the servlet and servlet-mapping parameters in the web.xml file under the web project, the solution to the 404 error is still reported when accessing with a browser:
The browser accesses the servlet: browser input address –> ip: port number/project name/path
is to match the value of url-pattern under the servlet-mapping configured in the web.xml file through the path under the project name, and then Use the value of servlet-name in servlet-mapping to match the value of servlet-name under servlet, and finally execute the class under servlet-class (limited class name);
Therefore, the following points should be paid attention to here:
1. The values of the two servlet-names must be the same;
2. The value of servlet-class should be the corresponding limited class name, that is, the form of "package name.class name";
3. If the above two places are correct, it is generally a problem with the value of url-pattern, if it is url The reason for the -pattern value is that the console will display an error when tomcat starts:
you can add a slash / in front of the value of url-pattern, restart tomcat and then visit the browser.
Personal experience, I hope it can help you!