idea build web project - super detailed tutorial

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
insert image description here

2. Create a new java module named webDemo1
insert image description here
insert image description here
3. Select webDemo1, right click, select Add Framework Support
insert image description here
and select Web Application
insert image description here

4. Create new folders classes and lib under WEB-INF
insert image description here
5. Open the project structure (Project Structure)
insert image description here
6. Project configuration
insert image description here
7, module configuration
insert image description here
insert image description here
8, Facets configuration, here the web directory is not an ordinary folder, but web Project
insert image description here
insert image description here
9. Configure Artifacts
insert image description here
insert image description here
10. Add Tomcat
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
11. Configure Deployment. This operation allows Tomcat to find the location of the war package, so as to
insert image description here
insert image description here
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.
insert image description here
insert image description here

insert image description here
insert image description here

insert image description here

insert image description here
insert image description here
insert image description here
insert image description here

insert image description here

insert image description here

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.
insert image description here
2. Write web.xml
insert image description here
3. Input and output statements in the service method
insert image description here
4. Input address
insert image description here/5 in the address bar and print out the console
insert image description here

Guess you like

Origin blog.csdn.net/stepleavesprint/article/details/127776102