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/
Note: here is recommended to use tomcat7 or tomcat8, the new version may have bugs,
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]
2. After opening, select [Advanced System Settings]
3. Click [Environmental Variables]
4. Find [System Variables], select [New]
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
6. Configure as follows under
Path Click Path, click [Edit]
7. Click [New] and paste the following two information:
%CATALINA_HOME%\lib
%CATALINA_HOME%\bin
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
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 .
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.
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.
In the conf directory, find the [logging.properties] configuration file
. 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
12. Run the startup.bat file or enter startup in the running window, and it is normal!
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]
and select in the following order
. After naming the project, click Finish.
The newly created project has the following directory structure:
src: store java code
web: store front-end code
as follows, right-click src, create two new packages, respectively named: classes and lib,
create two directories as
follows, click [File ] -> [Project Structure]
in order to select the following steps
to select the folder, find the package before classes created position
consistent path two paths:
select Dependencies -> + [number] -> [JARs or directories]
found before creating the lib package Click [ok] to
select [Jar Directory] and click [ok]. At
this time, the lib package is configured. Click [Apply] -> [ok].
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.
Now let us configure the tomcat server built in idea!
Click [Run] -> [Edit Configurations]
and then click [+] -> [Tomcat Server] -> [Local]
Proceed as follows to name the tomcat server: tomcat2 , click [Deployment], [+] and
select [Artifact]
to change the content of the automatically generated [Application context] to the following: At
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]
Write some text and code in the index.jsp file,
then start the Tomcat server, and click the green triangle.
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
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!
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~