第一种是在Tomcat根目录的 conf/server.xml :打开server.xml,找到<Host>元素 ,在其中添加如下代码
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="hello44" docBase="G:/Java/hello4"/>
</Host>
path为网页地址栏中输入的名称,docBase为web项目所在地。
第二种是在 conf/Catalana/localhost 目录下创建一个.xml的文件(此时的文件名就是地址栏的输入名),并在该文件中编写以下代码即可。
<Context docBase="G:/Java/hello"/>
浏览器的访问地址就是 http://localhost:8080/hello55 (因为.xml文件名就是hello55,所以输入hello55)