JavaWeb: Tomcat configuration (idea version) from installation to configuration, one-stop service

After reading this article, do you dare to say that you do not know how to configure tomcat?

When learning javaweb, the first step is to configure the tomcat server, here is how to configure the tomcat environment and how to configure the tomcat in the idea.
1. First, install the tomcat
official website: http://tomcat.apache.org/
Insert picture description here
Note: here is recommended to use tomcat7 or tomcat8, the new version may have bugs,
Insert picture description here
click on the compressed package in zip format to download it!
2. Configure tomcat

0. Decompress the tomcat compressed package just downloaded

Note: Before configuring tomcat, you must first install JDK (JDK1.7 is recommended, one-click installation of jre and jdk) to
configure the environment variables of tomcat:

1. Right-click [this computer] to find [Properties]
Insert picture description here

2. After opening, select [Advanced System Settings]
Insert picture description here

3. Click [Environmental Variables]
Insert picture description here

4. Find [System Variables], select [New]
Insert picture description here

5. Configure according to the following information (Note: the variable value is a position before the bin directory of tomcat), and then click [OK]

Variable name: CATALINA_HOME
Variable value: G:\tomcat\apache-tomcat-7.0.106\apache-tomcat-7.0.106
Insert picture description here
6. Configure as follows under
Path Click Path, click [Edit]
Insert picture description here

7. Click [New] and paste the following two information:

%CATALINA_HOME%\lib
%CATALINA_HOME%\bin
Insert picture description here

8. After the environment variables are configured, in order to prevent the crash after running startup.bat, we start to configure the tomcat resource file.

In the bin directory of the tomcat decompression directory, find the setclasspath.bat file
G:\tomcat\apache-tomcat-7.0.106\apache-tomcat-7.0.106\bin

Insert picture description here
9. After opening as a notepad, add the following information

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
set JRE_HOME=C:\Program Files\Java\jre1.8.0_131

These two paths are the installation paths of your jdk and jre .
Insert picture description here
10. After saving and closing, run the startup.bat file in the bin directory of the decompressed file of tomcat, and there will be no crash at this time.
Insert picture description here
11. But after running startup.bat, the log log of the tomcat terminal may be garbled, don't worry, only one encoding format needs to be configured here.
There is a conf file under the bin file.
Insert picture description here
In the conf directory, find the [logging.properties] configuration file
Insert picture description here
. Open the file in the form of a notepad and find
java.util.logging.ConsoleHandler.encoding=UTF-8 and
change it to:
java.util .logging.ConsoleHandler.encoding = GBK
save and close
Insert picture description here
12. Run the startup.bat file or enter startup in the running window, and it is normal!
Insert picture description here
Insert picture description here
The client configuration of tomcat is over here!

Let's start the configuration of idea

1. First, create a new web project [File]->[New]->[Project]
Insert picture description here
and select in the following order
Insert picture description here
. After naming the project, click Finish.
Insert picture description here
The newly created project has the following directory structure:
src: store java code
web: store front-end code
Insert picture description here
as follows, right-click src, create two new packages, respectively named: classes and lib,
Insert picture description here
create two directories as
Insert picture description here
follows, click [File ] -> [Project Structure]
Insert picture description here
in order to select the following steps
Insert picture description here
to select the folder, find the package before classes created position
Insert picture description here
consistent path two paths:
Insert picture description here
select Dependencies -> + [number] -> [JARs or directories]
Insert picture description here
found before creating the lib package Click [ok] to
Insert picture description here
select [Jar Directory] and click [ok]. At
Insert picture description here
this time, the lib package is configured. Click [Apply] -> [ok].
Insert picture description here
At this time, classes and lib have undergone slight changes, which will be introduced later The jar package can be placed under the lib package.
Insert picture description here
Now let us configure the tomcat server built in idea!

Click [Run] -> [Edit Configurations]
Insert picture description here
and then click [+] -> [Tomcat Server] -> [Local]
Insert picture description here

Proceed as follows to name the tomcat server: tomcat2 , click [Deployment], [+] and
Insert picture description here
select [Artifact]
Insert picture description here
to change the content of the automatically generated [Application context] to the following: At
Insert picture description here
this time, the tomcat server has no red cross

Configure as follows (the port number can be set as the default port number 80), click [Apply] -> [ok]

Insert picture description here
Write some text and code in the index.jsp file,
Insert picture description here
then start the Tomcat server, and click the green triangle.
Insert picture description here
At this point, the server starts, and the tomcat log information will be displayed in the console.
If it shows successful, it means that the server started successfully
Insert picture description here
in the browser. Enter the URL address: localhost:8081

The following information is displayed, proving that the tomcat server embedded in idea is successfully configured!
Insert picture description here
Next, start the learning journey of JavaWeb!

The installation packages of jdk1.8 and tomcat7.0 are as follows:
Link: https://pan.baidu.com/s/1W2VLnM1hAo2d8OGWRaomLg
Extraction code: 0002

The code word is not easy, and it is OK and cherish! ! !

Please indicate the source! ! !

Hematemesis and sort it out, give me three companies, thank you~

Guess you like

Origin blog.csdn.net/weixin_45088667/article/details/108943657