tomcat 配置ip地址访问不用加端口和项目名

主要配置tomcat/conf目录下的server.xml文件

1、先找到8080端口,把端口改为80。

<!-- A "Connector" represents an endpoint by which requests are received  
       and responses are returned. Documentation at :  
       Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)  
       Java AJP  Connector: /docs/config/ajp.html  
       APR (HTTP/AJP) Connector: /docs/apr.html  
       Define a non-SSL HTTP/1.1 Connector on port 8080  
  -->  
  <Connector port="80" protocol="HTTP/1.1"  
             connectionTimeout="20000"  
             redirectPort="8443" />  
  <!-- A "Connector" using the shared thread pool-->  

备注:设置Connector 节点的port="80"。

 

2、配置项目目录访问。

 <Host name="localhost"  appBase="webapps/lotter"  
          unpackWARs="true" autoDeploy="true"  
          xmlValidation="false" xmlNamespaceAware="false">  
<Context path="" docBase="lottery" />  
<!--<Context path="/lottery" docBase="." /> --> 

备注:设置Host 节点的name=“localhost”,name 是设置访问方式,用localhost访问的话自己本机直接使用localhost就可以访问web项目了,其它局域网可以直接通过本地连接的IP就可以访问了。 appBase=“webapps/lottery”,webapps应用程序目录,这里我设置的是webapps/lottery的相对目录。项目绝对路径就是(D:/apache-tomcat-7.0.65/webapps/lottery)也就是tomcat下的webapps下的i18n部署的项目目录。

3、tomcat启动时项目重复加载两次

appBase="webapps"配置可有可无。将项目lottery放在webapps同一路径下

<Host name="localhost"  unpackWARs="true" autoDeploy="true"  
               xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="D:/apache-tomcat-7.0.65/lottery" debug="0" reloadable="true" /> 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值