ntext>元素(这是最为普遍的方法)
在<Host>下配置多个<Context>元素
<Context path="app1" docBase="E:/workspace/app1/WebRoot" debug="0" reloadable="true"></Context>
<Context path="app2" docBase="E:/workspace/app2/WebRoot" debug="0" reloadable="true"></Context>
然后通过 主机名:端口/应用名 访问,如: http://localhost:8080/app1 或 http://localhost:8080/app2
2.通过配置多个<Host>元素
在<Engine>下配置多个<Host>元素
<Host appBase="webapps" name="192.168.1.110">
<Context path="" docBase="E:/workspace/app1/WebRoot" debug="0" reloadable="true"></Context>
</Host>
<Host appBase="webapps" name="192.168.1.114">
<Context path="" docBase="E:/workspace/app2/WebRoot" debug="0" reloadable="true"></Context>
</Host>
然后通过 主机名:端口 访问,如: http://192.168.1.110:8080 或 http://192.168.1.114:8080
需要注意的是这样需要机器连接到局域网上.
3.通过配置多个<Service>元素(多端口 多应用)
在<Server>下配置多个<Service>元素
<Service name="Catalina">
<Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8453" maxSpareThreads="75" maxThreads="150" minSpareThreads="25"/>
<Connector port="8019" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8453"/>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
<Context path="" docBase="E:/workspace/app1/WebRoot" debug="0" reloadable="true"></Context>
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
</Service>
<Service name="Catalina2">
<Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8090" redirectPort="8453" maxSpareThreads="75" maxThreads="150" minSpareThreads="25"/>
<Connector port="8019" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8453"/>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
<Context path="" docBase="E:/workspace/app2/WebRoot" debug="0" reloadable="true"></Context>
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
</Ser