Tomcat中更改网站根目录和默认页的配置方法

来源:互联网 发布:java建立个人博客网站 编辑:程序博客网 时间:2024/05/17 03:10

出处:
http://blog.csdn.net/u011101881/article/details/37569315

1.tomcat原来的默认根目录是http://localhost:8080,如果想修改访问的根目录,可以这样:
找到tomcat的server.xml(在conf目录下),找到:

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

插入:

    <Context path="" docBase="G:\workspace\BLTest\WebContent" reloadable="true" workDir="D:\tomcatApp\work" debug="0"/></Host>

其中G:\workspace\BLTest\WebContent就是我想设置的网站根目录,然后重启tomcat。

再次访问http://localhost:8080时,就是直接访问D:/eclipse3.3/jb51.NET/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>
阅读全文
0 0
原创粉丝点击