从浏览器角度看,connector元素定义具体请求协议、端口等参数。host元素(所谓的虚拟主机)把客户端请求地址与服务器上的源文档路径联系起来,如:
<host name="www.abc.com" appbase="abcapps" unpackwars="true" autodeploy="true" xmlvalidation="false" xmlnamespaceaware="false" />指定源文档目录在$CATALINA_HOME/abcapps/ROOT下(ROOT目录必须要有)。而context元素用于指定(1)子web应用目录;(2)web应用所涉及的各种资源(如JNDI)。如,对前述www.abc.com虚拟主机定义如下context:
<context path="/cqq" docbase="/web/cqqapp" debug="0" reloadable="true" crosscontext="true" />则源文档位于/web/cqqapp下,而客户端可以如此使用该应用:http://www.abc.com/cqq。关于context元素的定义位置,参见tomcat 6.0的在线文档如下:
Context elements may be explicitly defined:另外,Context的path属性通常不必设置,除非将Context定义在server.xml中,因为该属性值可以由该文件所在目录名称或文件名称或docBase属性推测得到。
* in the $CATALINA_HOME/conf/context.xml file: the Context element information will be loaded by all webapps
* in the $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host
* in individual files (with a ".xml" extension) in the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml) extension will be used as the context path. Multi-level context paths may be defined using #, e.g. context#path.xml. The default web application may be defined by using a file called ROOT.xml.
* if the previous file was not found for this application, in an individual file at /META-INF/context.xml inside the application files
* inside a Host element in the main conf/server.xml
一个不错的参考帖:Tomcat配置多域名绑定和虚拟目录
没有评论:
发表评论