方法一:
\conf\server.xml
<Host>內插入<Context path="虛擬目錄" docBase="文件目錄" />
<Context path="虛擬目錄" docBase="文件目錄" />
注:需重啟Tomcat
方法二:
\conf\Catalina\localhost
新建文件 虛擬目錄.xml 文件內寫入
<Context path="" docBase="文件目錄" />
注:
多級目錄寫法 虛擬一級目錄#虛擬二級目錄#虛擬三級目錄.xml
根目錄起始頁設置
\conf\Catalina\localhost
1.新建文件 ROOT.xml 文件內寫入
<Context path="" docBase="文件目錄" />
2.文件目錄下新建必須文件夾 "WEB-INF","WEB-INF"下新建文件夾"classes"和"lib"
3.新建文件 web.xml 文件內寫入
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<welcome-file-list>
<welcome-file>起始頁1.html</welcome-file>
<welcome-file>起始頁2.html</welcome-file>
<welcome-file>起始頁3.html</welcome-file>
</welcome-file-list>
</web-app>
本地域名映射
1.C:\Windows\System32\drivers\etc\hosts
127.0.0.1 域名
2.\conf\server.xml
<Engine></Engine>內插入
<Host name="域名" appBase="域名基准文件路徑">
<Context path="虛擬目錄" docBase="文件路徑(相對基准文件路徑)"/>
</Host>
*端口
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

