Some problems in learning Tomcat

Time:2020-11-25

Tomcat installation configuration

  1. First, you need to configure Java_ Home and JRE_ The environment variable of home, the address is the Java root directory path, such as F: \
  2. Download the installation free compressed package from Tomcat website.
  3. After decompression, the DOS window enters the bin file, and then runs to the service startup, such asSome problems in learning TomcatAfter that, a service window will be openedSome problems in learning Tomcat
  4. You can access the resource files under the webapps folder in the Tomcat root directory. First, create a new folder named test under the webapps folder, and put a 1.jpg picture in the test folder. Browser accesshttp://localhost: 8080 / test / 1. JPG,, you can see this picture. The general default port number is 8080
  5. To shut down the service, enter shutdown in the DOS window, and the service window will shut down automatically.

There are two main types of commands (tombin, which are used to store the. Tombat. Linux) at the end.

Tomcat directory structure

Bin directory is mainly used to modify environment variables and set JDK path and Tomcat path
Startup is used to start Tomcat
Shutdown is used to shut down Tomcat
The memory of Tomcat can be set by modifying Catalina

The conf directory is mainly used to store some configuration files of Tomcat
server.xml You can set port number, domain name or IP, default loaded project and request code
web.xml You can set the file types supported by Tomcat
context.xml Can be used to configure data sources and so on
tomcat- users.xml Used to configure and manage Tomcat users and permissions
You can set the default loaded project in Catalina directory
The Lib directory is mainly used to store the jar packages that Tomcat needs to load
For example, we can add JDBC packages to the Lib directory.
The logs directory is used to store the log files generated during the operation of Tomcat
In the windows environment, the output log of the console is in the catalina.xxxx -xx- xx.log In the file
In the Linux console, the output is in the Linux console catalina.out In the file
Temp directory the user stores the temporary files generated by Tomcat during the running process

The webapps directory is used to store applications
When Tomcat starts, it will load the application under the webapps directory. The application can be released in the form of folder, war package and jar package.
Of course, you can also put the application anywhere on the disk and map it in the configuration file.
The work directory is used to store the compiled files of Tomcat at runtime
For example, JSP compiled files.
Clear the work directory and restart Tomcat to clear the cache.

Cattoma configuration

Navigation bar run > configure edit
Some problems in learning Tomcat
Add new configuration > select Tomcat server > local
Some problems in learning Tomcat
Write the name, here the two port numbers are automatically generated, confirm
Note that once the port number is occupied, there will be an error if the service fails to run

After that, click the green plus sign at the bottom left of idea, and the run service will run
Some problems in learning Tomcat

Some problems in learning Tomcat

Tomcat service run error port out of range:-1

Solution: modify the server.xml , will
< server port = – 1 “shutdown =” shutdown “> changed to
< server port = any integer between 1-65535 “shutdown =” shutdown “>,

Tomcat garbled code

It’s annoying….
Some problems in learning Tomcat

Solution: find the logging.properties file
Open and add at the end

java.util.logging.ConsoleHandler.encoding = GBK~~~~

Some problems in learning Tomcat
OK, it worked!

Some problems in learning Tomcat