日期:2014-05-19  浏览次数:20608 次

如何用tomcat设置多个端口
如何用tomcat设置多个端口,使每个程序分别对应不同的端口   比如http://localhost:8080  的时候访问 project1; 比如http://localhost:8085  的时候访问 project2; 比如http://localhost:8086  的时候访问 project3
------最佳解决方案--------------------
server.xml默认的
<Service name="Catalina">
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
    <Connector port="8009" 
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="project1.war" path="/project1" auth="Container">
  <Resource
      name="testDb"
      type="javax.sql.DataSource"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      maxIdle="2"
      maxWait="5000"
      username="1234"
      password="1234"
      url="jdbc:oracle:thin:@127.0.0.1:1521:testora"
      maxActive="4"/>
</Context>
      </Host>
    </Engine>
  </Service>

你自己添加一个:
<Service name="tttttt">
    <Connector port="8088" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8448" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
    <Connector port="8089" 
               enableLookups="false" redirectPort="8448" protocol="AJP/1.3" />
    <Engine name="tttttt" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhos