Deploying web projects in Tomcat has http status -404 - no detailed solution found

Problem Description:

When we initiate a request to the tomcat server, the following error status prompt appears – 404. This problem may be encountered frequently during the development process, so make a summary: the following content is applicable to IDEA, and friends who use other
insert image description here
editors We need to notice the difference.

Scenario ①
–> The accessed resource does not exist, carefully check whether the file name is consistent with the file name in the path, for example: hello.jsp is written as hallo.jsp.

Scenario ②
–> The virtual path is not written correctly, you can check the virtual path name in the configuration tomcat, the general request path contains the virtual path name (or not), for example: http://localhost:8080/chapter08 / test.jsp
insert image description here
Scenario ③
–> The accessed servlet resource file is not configured in web.xml , or the annotation @WebServlet("/test") is not added to the corresponding servlet class .

Scenario ④
–> The relevant dependent jar packages are not added to the project and need to be added manually. After checking, I found that there is no problem, but it still reports 404. The solution is: determine whether the jar package has been published to the class path.

Click in turn: File->ProjectStructure->Artifacts
insert image description here
to add all dependent jar packages of the project to the lib directory, click the + sign, select the first item, and copy and paste the contents of project libraries in the opened page.
insert image description here
Summary: More than 90% of the mistakes appear in the details, and the remaining 10% of the mistakes appear in the incomplete grasp of the knowledge points. There is no learning, only not learning.

Guess you like

Origin blog.csdn.net/weixin_48627356/article/details/122527135