tomcat 虛擬目錄
<Host name="www.baidu.com.cn" appBase="webapps2"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" >
<Context path="/" docBase="/web" />
</Host>
2.在tomcat根目錄下創建webapps2,子目錄web,分別對應虛擬目錄裏面的 appBase,docBase
<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_2_5.xsd"
version="2.5">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<welcome-file-list>
<welcome-file>test.html</welcome-file>
</welcome-file-list>
<error-page>
<error-code>500</error-code>
<location>/error.html</location>
</error-page>
</web-app>
test.html<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>hello world</h1>
</body>
</html>
4.修改本地的hosts文件,目錄是在C:\WINDOWS\system32\drivers\etc\hosts。