Tomcat配置文件server.xml - unbelieveus
Tomcat目录中的server.xml配置文件
server.xml称为主配置文件或全局配置文件
它完成以下两个目标:
1,提供Tomcat组件的初始化配置
2,说明Tomcat的结构和含义,使得Tomcat通过实例化组件完成启动及构建自身
代码解析如下:
<span style="font-size: 15px; color: #0000ff;"><span style="font-size: 16px;"><strong> <<span style="color: #ff00ff;">Server</span> port="8005" shutdown="SHUTDOWN"> <<span style="color: #ff00ff;">Listener</span> className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <<span style="color: #ff00ff;">Listener</span> className="org.apache.catalina.core.JasperListener" /> <<span style="color: #ff00ff;">Listener</span> className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <<span style="color: #ff00ff;">Listener</span> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <<span style="color: #ff00ff;">Listener</span> className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <<span style="color: #ff00ff;">GlobalNamingResources</span>> <span style="color: #ff0000;"><!-- 全局命名资源,来定义一些外部访问资源,其作用是为所有引擎应用程序所引用的外部资源的定义 --!></span> <<span style="color: #ff00ff;">Resource</span> name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </<span style="color: #ff00ff;">GlobalNamingResources</span>> <span style="color: #ff0000;"><!-- 定义的一个名叫“UserDatabase”的认证资源,将conf/tomcat-users.xml加载至内存中,在需要认证的时候到内存中进行认证 --></span> <<span style="color: #ff00ff;">Service</span> name="Catalina"> <span style="color: #ff0000;"> <!-- # 定义Service组件,同来关联Connector和Engine,一个Engine可以对应多个Connector,每个Service中只能一个Engine --!></span> <<span style="color: #ff00ff;">Connector</span> port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <span style="color: #ff0000;"> <!-- 修改HTTP/1.1的Connector监听端口为8080.客户端通过浏览器访问的请求,只能通过HTTP传递给tomcat。 --></span> <<span style="color: #ff00ff;">Connector</span> port="8009" protocol="AJP/1.3" redirectPort="8443" /> <<span style="color: #ff00ff;">Engine</span> name="Catalina" defaultHost="localhost"> <span style="color: #ff0000;"> <!-- 修改当前Engine,默认主机是localhost --></span> <<span style="color: #ff00ff;">Realm</span> className="org.apache.catalina.realm.LockOutRealm"> <<span style="color: #ff00ff;">Realm</span> className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </<span style="color: #ff00ff;">Realm</span>> <span style="color: #ff0000;"> <-- Realm组件,定义对当前容器内的应用程序访问的认证,通过外部资源UserDatabase进行认证 --></span> <<span style="color: #ff00ff;">Host</span> name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <span style="color: #ff0000;"> <!-- 定义一个主机,域名为:localhost,应用程序的目录是webapps,设置自动部署,自动解压 --></span> <<span style="color: #ff00ff;">Context</span> path="" docBase=""/usr/local/tomcat/webfile" " reloadable="true" /> <span style="color: #ff0000;"> <!--定义该应用程序,访问路径"“,并且当该应用程序下web.xml或者类等有相关变化时,自动重载当前配置,即不用重启tomcat使部署的新应用程序生效--></span> <<span style="color: #ff00ff;">Valve</span> className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> <span style="color: #ff0000;"> <!-- 定义一个Valve组件,用来记录tomcat的访问日志,日志存放目录为:logs如果定义为相对路径则是相当于$CATALINA_HOME,</span></strong></span><strong><span style="color: #ff0000;">并非相对于appBase,</span><br /><span style="color: #ff0000;"> 这个要注意。定义日志文件前缀为<span style="font-size: 15px;"><span style="font-size: 16px;"><strong>localhost_access_log</strong></span></span>并以.txt结尾,pattern定义日志内容格式,具体字段表示可以查看tomcat官方文档--></span> </<span style="color: #ff00ff;">Host</span>> </<span style="color: #ff00ff;">Engine</span>> </<span style="color: #ff00ff;">Service</span>> </<span style="color: #ff00ff;">Server</span>> </strong></span>
标签功能如下:
server标签:根元素,它代表整个容器,是Tomcat实例的顶层元素.由org.apache.catalina.Server接口来定义.它包含一个
Listener标签:监听器,用来管理Tomcat生命周期和全局资源
GlobalNamingResources标签:配置系统的JNDI
Service标签:该元素由org.apache.catalina.Service接口定义,它包含一个
Connector标签:连接器,代表外部客户之间的接口,将在一个指定的接口上侦听客户请求,将请求给Engine进行处理Connector之间的port不能重复,否则会报JVM BIND 端口号冲突的问题
Enger标签:引擎,每个Service元素只能有一个Engine元素.元素处理在同一个
Realm标签:定义对当前容器内的应用程序访问的认证,通过外部资源UserDatabase进行认证
Logger标签:
Host标签:它由Host接口定义.一个Engine元素可以包含多个
Logger标签:日志和错误信息
Context标签:web应用组,它由Context接口定义.是使用最频繁的元素.每个

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.
