Create a javaweb project under the 500 error idea to deploy and run

The basic steps:

 

1. Create a new project - create a new module
2. Add web to the module
3. Create artifact - deployment package
4. lib - artifact
   There is artifact first, and mysql.jar is added later. At this time, the jar package has not been added to the deployment package
   , so there will be a prompt in ProjectSettings in Problems, we click fix and select add to...

   Sometimes there may be no prompts. At this time, we need to manually add the lib in the project. See the graphic explanation below
   . In addition, we can also directly create the lib folder under WEB-INF.
   The bad thing about this is that this lib can only be exclusive to the current moudle. If there is a second moudle we need to repeat the new lib again.
5. When deploying, modify the application Context. Then go back to the server tab and check the URL value.
   The value of the URL refers to the URL that automatically opens the browser you specify after the tomcat startup is complete, and then visits by default.
   After startup, error 404.404 means that the specified resource cannot be found.
   If our URL is: http://localhost:8080/pro01/ , it means that we are visiting index.html.
   We can set the welcome page through the <welcome-file-list> tag (in tomcat's web.xml settings, or set in the web.xml of your own project)
6. 405 problems. The method currently requested is not supported. For example, if we form method=post, then the Servlet must correspond to doPost. Otherwise, a 405 error will be reported.
7. Null pointer or NumberFormatException. Because there are prices and stocks. If the price cannot be obtained, you will report an error if you want to perform Integer.parseInt() on null. The reason for the error is mostly because the name="price" is wrongly written here, and as a result, request.getParameter("price") is still used to obtain it on the Servlet side.
8. <url-pattern> begins with a slash
The 9.500 error may be a problem in step 4. The jar package mysql.jar has not been added to the deployment package. The lib folder can be created under WEB-INF, or the variable name corresponding to AddServlet is wrong

Project map after completion:

 For the jar package in lib, we don’t need to add it separately. You can put it in the folder and directly select the folder and right-click Add as library. You can also click Export in modules and click the plus sign to select the folder to add.       

 You can also click the plus sign in the libraries to select the folder to add

500 error

Here I am aiming at the 500 error encountered when completing the form filling in the Javaweb and wanting to send the content to the server.

Don't forget to add the lib library to the modules,

If lib is placed under the large project file Web, if the situation in the figure below appears, double-click lib to add it to the module's WEB-INF, Artifacts deployment package

 After double-clicking:


 

Guess you like

Origin blog.csdn.net/Sciws/article/details/124612749