1. Idea builds web projects
Idea's super detailed tutorial for building web projects, step by step, no problem at all!
1. Create a new empty project
2. Create a new java module named webDemo1
3. Select webDemo1, right click, select Add Framework Support
and select Web Application
4. Create new folders classes and lib under WEB-INF
5. Open the project structure (Project Structure)
6. Project configuration
7, module configuration
8, Facets configuration, here the web directory is not an ordinary folder, but web Project
9. Configure Artifacts
10. Add Tomcat
11. Configure Deployment. This operation allows Tomcat to find the location of the war package, so as to
deploy the web project on the Tomcat server . Import lib (2) Import jar related to tomcat 13, configuration is complete, run service 14, run successfully.
2. Write your first servlet
1. Create a new java class to implement the Servlet interface, and implement 5 abstract methods.
GenericServlet can also be inherited. At this time, you only need to implement the service() method.
You can also inherit the HttpServlet class. At this time, you only need to rewrite the doGet() method or the doPost() method.
2. Write web.xml
3. Input and output statements in the service method
4. Input address
/5 in the address bar and print out the console