(Hands-on nanny-level tutorial) From 0 to Tomcat, my first Tomcat web page

Table of contents

1. Go to Tomcat official website to download a Tomcat

 1.1 Select the download method

1.1.1 Click Tomcat9 under Download (take 9 as an example here)

1.1.2 Click the zip file under core

 1.2 Unzip the package after the download is complete

1.2.1 Select the entire compressed package, click to decompress to

1.2.2 Choose a suitable directory to place (the path should not contain Chinese)

2. Configure environment variables (here, by default, at least one JDK has been installed in your computer)

2.1 Configure JAVA_HOME

2.1.1 Right click on My Computer--->Properties--->Advanced System Settings

2.1.2 Click Environment Variables

2.2 Configure CLASSPATH

 2.3 Configure the CATALINA_HOME variable

 2.4 Configure the PATH variable

2.5 Set JAVA_HOME path in Tomcat

3. Try to start Tomcat

3.1 Open Tomcat with the command line

3.1.1 Open the cmd command line program

3.1.2 After entering the bin directory under the Tomcat installation directory, enter the command startup to start Tomcat

3.2 (console output garbled solution):

 3.2.1 Add encoding format to server:

 3.2.2 Change the format of the character information output by the console:

4. Create a new project in the idea

4.1new a project project

 4.1.1 Select project path

 4.2 Add web dependencies

 4.3 Configure Tomcat in idea

4.3.1 Click Add Configuration next to the small hammer

4.3.2 Select Local under Tomcat Server

​edit

4.3.3 Click Deployment next to Server to deploy

4.3.4 Then click the plus sign and select Artifact

4.3.5 Click OK, the deployment is complete, and you can see a Tom cat coming out, and there is also a run button next door.

5 opens a new world


1. Go to Tomcat official website to download a Tomcat

Tomcat official website address: https://tomcat.apache.org/

There are many versions to choose from, it is recommended to download 8 or 9 here

Official website interface:

 1.1 Select the download method

1.1.1 Click Tomcat9 under Download (take 9 as an example here)

 

1.1.2 Click the zip file under core

 1.2 Unzip the package after the download is complete

1.2.1 Select the entire compressed package, click to decompress to

1.2.2 Choose a suitable directory to place (the path should not contain Chinese)

        This file will appear after decompression:

2. Configure environment variables (here, by default, at least one JDK has been installed in your computer)

2.1 Configure JAVA_HOME

2.1.1 Right click on My Computer--->Properties--->Advanced System Settings

2.1.2 Click Environment Variables

Create a new JAVA_HOME variable in the system variable

(You can also directly browse your JDK installation location, pay attention to the installation location of JDK, just select the entire folder directly)

2.2 Configure CLASSPATH

The same is true, create a new CLASSPATH variable         in the system variable

Here you can directly copy my code and paste it (a pointer similar to the pointer in C language is used, if you change the JDK in the future, you can modify the address in JAVA_HOME)

.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

 2.3 Configure the CATALINA_HOME variable

The path here selects the path you just installed Tomcat 

 2.4 Configure the PATH variable

Find the PATH variable in the system variables, click "Edit", "New", and add this code (the pointer of the pointer is also used)

%CATALINA_HOME%\lib;%CATALINA_HOME%\bin

2.5 Set JAVA_HOME path in Tomcat

Open setclasspath.bat with Notepad in the bin directory under the directory where Tomcat is installed

Adding the path of JAVA_HOME around line 21 is actually the path of JDK

3. Try to start Tomcat

3.1 Open Tomcat with the command line

3.1.1 Open the cmd command line program

3.1.2 After entering the bin directory under the Tomcat installation directory, enter the command startup to start Tomcat

3.2 (console output garbled solution):

 3.2.1 Add encoding format to server:

Find the server.xml file in the conf directory of the Tomcat installation directory, open it with Notepad and locate it to line 71 and add a line of encoding:

URIEncoding="UTF-8"

 3.2.2 Change the format of the character information output by the console:

Change the output format to GBK around line 51

After the modification is complete, start Tomcat again and you will find that the console has output Simplified Chinese.

After configuring Tomcat, we try to create a new project in idea and run it

4. Create a new project in the idea

4.1new a project project

 Just go to the next step

  Just go to the next step

 4.1.1 Select project path

 4.2 Add web dependencies

Right click in the Test root directory and select Add Framework Support

 Check Web Application and click finish

 After the creation is complete, we can see that there is a web directory with a blue dot under the project

 4.3 Configure Tomcat in idea

4.3.1 Click Add Configuration next to the small hammer

4.3.2 Select Local under Tomcat Server

 The following interface will pop up 

At this time, we saw a red exclamation mark below, and then eliminated it

4.3.3 Click Deployment next to Server to deploy

4.3.4 Then click the plus sign and select Artifact

 

 At this point, you can see that the exclamation mark has disappeared, so that we have configured the path for accessing in the browser later (the path here can also be changed, because we will not change the default for the first time)

4.3.5 Click OK , the deployment is complete, and you can see a Tom cat coming out, and there is also a run button next door.

 

5 opens a new world

This inde.jsp is an interface that will be opened automatically after we successfully run Tomcat in the idea later

We enter hello world under the body tag

 Finally click the run button in step 4.3.5

But after a while, we can see that the operation information in simplified Chinese has been output in our console!

After running successfully, the browser will automatically open : Hello World!

 So far we have learned the operation from 0 to the successful configuration of Tomcat. If you have any questions, please leave a message in the comment area.

 

 

Guess you like

Origin blog.csdn.net/Banxia228/article/details/127584806