<?xml version='1.0' encoding='utf-8'?>
<Server port="8085" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8089" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="127.0.0.1" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!--
<Context path="/" docBase="E:\\project\\j2ee\\web" debug="0" reloadable="false" />
-->
<!--
<Context path="/fleafair_sdu" docBase="G:\\fleafair_sdu\\web" debug="0" reloadable="false" />
-->
<Context path="" docBase="/web" debug="0" reloadable="false" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
红色部分有三处,是需要添加或修改的地方。
第一处,port="8080"是指端口号,tomcat默认的端口号是8080,可以把端口号修改成80,即port="80",修改为80后必须保证80端口没有被其他程序占用才可以。
第二处,name="127.0.0.1",server.xml文件中原本写的是localhost,我这里改成了127.0.0.1,你也可以改成对应的自己的ip地址,
第三处,添加红色部分的文本,web是webapps下的一个文件夹,将准备测试的文件放到web里面,如html文件,在浏览器输入http://127.0.0.1:8080/测试文件名