The get method directly accesses the servlet, the servlet class cannot be found, and the exception java.lang.classnotfoundexception and 404 error are reported.

1. This directory is the specification of jsp and servlet! The user-defined classes used when jsp and servlet are running will be found directly in /web-inf/classes! Even if you set it in the environment variable, the servlet container will not recognize it! But the java virtual machine can be found! So with javac can be compiled through! But it can't be found when the container is running! Its path location cannot be changed in general, otherwise the required class will not be loaded, and classnotfoundexception will be reported naturally. The compiled .class file must be placed in the classes folder, and the classes file must be placed in the web-inf folder.

2. If servlet is configured in web.xml, and you add the @WebServlet annotation to the servlet class you wrote, and the url-partten is the same, 404 will be reported.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326003501&siteId=291194637