一、图解服务器处理过程
蓝色为需要配置的地方,橙色不用管。
二、重要参数解析
<?xml version=”1.0″ encoding=”utf-8″?>
<Server port=”8003″ shutdown=”SHUTDOWN”>
//shutdown指定终止Tomcat服务器运行时,发给Tomcat服务器的shutdown监听端口的字符串.
<Listener className=”org.apache.catalina.core.AprLifecycleListener” SSLEngine=”on” />
<Listener className=”org.apache.catalina.core.JasperListener” />
<Listener className=”org.apache.catalina.core.JreMemoryLeakPreventionListener” />
<Listener className=”org.apache.catalina.mbeans.GlobalResourcesLifecycleListener” />
<GlobalNamingResources>
<Resource 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” />
</GlobalNamingResources>
<Service name=”Catalina”>
//第一个<Service>处理所有直接由Tomcat服务器接收的web客户请求.
<Connector port=”80″ protocol=”HTTP/1.1″ disableUploadTimeout=”true” maxHttpHeaderSize=”8192″ acceptCount=”1000″ maxThreads=”1000″ minSpareThreads=”25″ maxSpareThreads=”75″ redirectPort=”8443″ enableLookups=”false” compression=”on” compressionMinSize=”2048″ compressableMimeType=”text/html,text/javascript,text/css,text/plain” connectionTimeout=”20000″ />
//<Connector>元素代表与客户程序实际交互的组件,它负责接收客户请求,以及向客户返回响应结果.
<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />
//第二个Connector元素定义了一个JD Connector,它通过8009端口接收由其它服务器转发过来的请求。
<Engine name=”Catalina” defaultHost=”localhost”> Engine的配置(表示指定service中的请求处理机,接收和处理来自Connector的请求)
<Realm className=”org.apache.catalina.realm.LockOutRealm”>
<Realm className=”org.apache.catalina.realm.UserDatabaseRealm” resourceName=”UserDatabase” />
</Realm>
<Host name=”localhost” appBase=”webapps” unpackWARs=”true” autoDeploy=”true”>
//host(表示一个虚拟主机),appBase:应用程序基本目录,即存放应用程序的目录
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs” prefix=”localhost_access_log.” suffix=”.txt” pattern=”%h %l %u %t "%r" %s %b” resolveHosts=”false” />
<Context path=”” docBase=”D:\paccp” debug=”0″ reloadable=”true” /> //Context(表示一个web应用程序,通常为WAR文件,关于WAR的具体信息见servlet规范)docBase:应用程序的路径或者是WAR文件存放的路径,path 表示此web应用程序的url的前缀,这样请求的url为http://localhost:8080/path/****
</Host>
</Engine>
</Service>
</Server>
三、Server文件结构图:
1:<server>
2:<service>
3:<Engine> <Connector>
4:<Host>
5:<Context>
1:</server>
2:</service>
3:</Engine> </Connector>
4:</host>
5:</Context>