标签:
一、组成结构
二、在Tomcat中发布Web应用
1.默认方式发布:将Web应用所有文件复制到Tomcat的<CATALINA_HOME>/webapps目录下,启动Tomcat服务器。
2.Web组件URL
<servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>mypack.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/dispatcher</url-pattern> </servlet-mapping>
如图:
3.配置Tomcat的<Context>元素发布Web应用
<Context>元素代表了运行在虚拟主机<Host>上的单个Web应用
Tomcat 6.x配置<Context>几种途径:
eg: <CATALINA_HOME>/conf/catalina/localhost/context.xml.default
eg: <CATALINA_HOME>/conf/catalina/localhost/helloapp.xml
<Context path="/helloapp" docBase="C:\chapter03\helloapp" reloadable="true"/>
path:Web应用URL入口
docBase:helloapp应用文件路径C:\chapter03\helloapp
<Context path="/helloapp" docBase="helloapp" reloadable="true"/>
path:Web应用URL入口
docBase:helloapp应用文件路径<CATALINA_HOME>/webapps/helloapp
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
<Context path="/helloapp" docBase="helloapp" reloadable="true"/> </Host>
4.配置Tomcat虚拟主机
步骤:
<Host name="www.mycompany1.com" appBase="C:\mycompany1" unpackWARs="true" autoDeploy="true"> <Alias>mycompany1.com</Alias> <Alias>mycompany1</Alias> </Host>
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 www.mycompany1.com
标签:
原文地址:http://www.cnblogs.com/EmmaPei0416/p/5835939.html