Home Web Front-end HTML Tutorial Tomcat配置文件server.xml - unbelieveus

Tomcat配置文件server.xml - unbelieveus

May 20, 2016 pm 01:46 PM

Tomcat目录中的server.xml配置文件

 

server.xml称为主配置文件或全局配置文件

它完成以下两个目标:

1,提供Tomcat组件的初始化配置

2,说明Tomcat的结构和含义,使得Tomcat通过实例化组件完成启动及构建自身

 

代码解析如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

<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;"><!-- 定义的一个名叫&ldquo;UserDatabase&rdquo;的认证资源,将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;">            <!--定义该应用程序,访问路径"&ldquo;,并且当该应用程序下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>

Copy after login

标签功能如下:

server标签:根元素,它代表整个容器,Tomcat实例的顶层元素.org.apache.catalina.Server接口来定义.它包含一个元素.并且它不能做为任何元素的子元素.(其直接子元素有3个)

   Listener标签:监听器,用来管理Tomcat生命周期和全局资源

   GlobalNamingResources标签:配置系统的JNDI

   Service标签该元素由org.apache.catalina.Service接口定义,它包含一个元素,以及一个或多个,这些Connector元素共享用同一个Engine元素(其直接子元素2个)

      Connector标签:连接器,代表外部客户之间的接口,将在一个指定的接口上侦听客户请求,将请求给Engine进行处理Connector之间的port不能重复,否则会报JVM BIND  端口号冲突的问题

      Enger标签:引擎,每个Service元素只能有一个Engine元素.元素处理在同一个中所有元素接收到的客户请求.org.apahce.catalina.Engine接口定义.处理server中所有的客户请求(其直接子元素3个)

        Realm标签定义对当前容器内的应用程序访问的认证,通过外部资源UserDatabase进行认证

        Logger标签

        Host标签它由Host接口定义.一个Engine元素可以包含多个元素.每个的元素定义了一个虚拟主机.它包含了一个或多个Web应用.虚拟主机处理一个特定的主机请求(其直接子元素2个)

          Logger标签:日志和错误信息

          Context标签:web应用组,它由Context接口定义.是使用最频繁的元素.每个元素代表了运行在虚拟主机上的单个 Web应用.一个可以包含多个元素.每个web应用有唯一的一个相对应的Context代表web应用自身.servlet容器为第一个web应用创建一个ServletContext对象.当一个web应用被初始化时,它将用自己的classLoader对象载入”web.xml“中定义的每个Servlet类。元素中可以包含如下元素, , ,

 

      

                                              

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

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.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

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.

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

See all articles