02_Tomcat——Two ways for Tomcat to deploy web projects

1. Tomcat is the first way to deploy web projects

The first deployment method: just copy the directory of the web project to the webapps directory of Tomcat

1. Create a project in the webapps directory:

Here we create a folder player

insert image description here

Then copy the content of a web project into it (the content of an html web page is used here)

insert image description here
So far the project has been deployed.

2. How to access the web project under Tomcat:

Just enter the access address format in the browser as follows:

  1. http://localhost:8080/project name/directory/file name
  2. http://ip address of computer: 8080/project name/directory/file name

Here we try to access the Home.html page in the web project
insert image description here

Type in your browser:

  1. http://localhost:8080/player/Home.html
  2. http://192.168.1.115(my ip address)/:8080/player/Home.html

Note here:
webapps under the tomcat path are equivalent to http://localhost:8080 of the access path
insert image description here

Successful visit! !
insert image description here
![Insert picture description here](https://img-blog.csdnimg.cn/b9dd11737e92451c9fac5427395026b2.png 500x)
If it is a LAN, you can try the following to access the project webpage deployed by the server in the same LAN (I am a computer Even mobile phones can access wifi)

Note: If it is connected by wifi, the computer ip should select the ip address in the wireless LAN adapter WLAN
insert image description here

2. Tomcat The second way to deploy web projects

The first deployment method: find the conf\Catalina\localhost\ under Tomcat, and create the following configuration file (create an xml file):
insert image description here

The content format in the abc.xml file is as follows:
it is equivalent to mapping the path E:\Html\player to the path /abc
Note: the path is /docBase is \
because /abc is needed when accessing in the browser, browse The path in the browser is separated by /
and the path in the computer is separated by \

insert image description here

After configuring the xml file, the project deployment task is completed.
Note: After modifying the xml file, you need to restart the Tomcat server, which may or may not have any effect.

How to access the web project under Tomcat:
The path to access this project is as follows:
http://localhost:8080/abc/
http://computer ip address/abc/

It means accessing the E:\Html\player directory

After configuring the above requirements, use the second deployment method to access the web project.
(Take access to Home.html in the player directory as an example. The path of Home.html is as follows)
insert image description here

The path to access this web is: http://localhost:8080/abc/Home.html

insert image description here

Successful visit!

Guess you like

Origin blog.csdn.net/qq_45657848/article/details/128768534