1、組成結構html
2、在Tomcat中發佈Web應用web
1.默認方式發佈:將Web應用全部文件複製到Tomcat的<CATALINA_HOME>/webapps目錄下,啓動Tomcat服務器。apache
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應用app
<Context>元素表明了運行在虛擬主機<Host>上的單個Web應用webapp
Tomcat 6.x配置<Context>幾種途徑:jsp
eg: <CATALINA_HOME>/conf/catalina/localhost/context.xml.default ui
eg: <CATALINA_HOME>/conf/catalina/localhost/helloapp.xmlurl
<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