Tomcat网站根目录修改

 时间:2026-05-02 01:07:45

1、tomcat原来的默认根目录是此昆新http://localhost:8080,菊宋如果想修改访问的根目录,可以这样:

找到tomcat的server.xml(在conf目录下),找到:

复制代码 代码如下:

<Host name="localhost" appBase="webapps"        unpackWARs="true" autoDeploy="true"        xmlValidation="false" xmlNamespaceAware="false">

</Host>

在</Host>前插入:

代码如下:

<Context path="" docBase="D:/eclipse3.3/jb51.net/tomcat/" debug="0"/>

其中D:/eclipse3.3/tomcat/就是我想设置的网站根目录,然后重启tomcat。

再次访问http://localhost:8080时,就是直接访问D:/eclipse3.3/tomcat/目录下的文件了。

2、tomcat的web.xml(在conf目录下),在该文件中找到

代码如下:

    <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。可以修改上面信息为:

代码如下:

   包慎 <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>

这样就OK了。

  • 1.6升以下小排量的国产自主汽车乘用车都有哪些
  • 欢乐六一手抄报
  • 世界四大美术学院是哪四所院校?好申请吗?
  • 乌鸡淮山汤的做法
  • 墙上挂什么画合适
  • 热门搜索
    逮的意思 意思的英文 调侃的意思 针式打印机什么牌子好 粗心的什么 厚德载物的意思是什么意思 什么是扮猪吃老虎 什么东西吃不胖 汽车挂件有什么讲究 金融社保卡有什么用