Tomcat中更改默认端口、更改默认根目录、更改默认页的配置方法

1、更改默认端口号:

Tomcat默认端口号为8080,如果想更改成其他端口,比如80,可以找到tomcat的server.xml(在conf目录下)

1
< Connector  port = "8080"  protocol = "HTTP/1.1"  connectionTimeout = "20000"  redirectPort = "8443"  />

把8080改为80即可。

2、更改默认根目录:

Tomcat默认根目录为ROOT目录,如果想更改到其他目录,比如/webapps/Test/,可以找到tomcat的server.xml(在conf目录下)

1
2
3
< Host  name = "localhost"   appBase = "webapps"            
      unpackWARs = "true"  autoDeploy = "true" >                     
</ Host >

在</Host>前插入:

1
< Context  path = ""  docBase = "你要设置的目录"  debug = "0" />

3、更改默认首页:

Tomcat的默认首页在web.xml(在conf目录下)中找到

1
2
3
4
5
< welcome-file-list >
    < welcome-file >index.html</ welcome-file >
    < welcome-file >index.htm</ welcome-file >
     < welcome-file >index.jsp</ welcome-file >
</ welcome-file-list >

这是tomcat默认的3个文件,当你输入指定路径后,tomcat会自动查找这3个页面。如果你想让tomcat自动找到自己的页面,比如main.jsp。可以修改上面信息为:

1
2
3
4
5
6
< welcome-file-list >
        < welcome-file >main.jsp</ welcome-file >
         < welcome-file >index.html</ welcome-file >
         < welcome-file >index.htm</ welcome-file >
         < welcome-file >index.jsp</ welcome-file >
</ welcome-file-list >


PS:当然以上所有操作完成后别忘了重启tomcat哦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值