Tomcat中更改网站根目录和默认页的配置方法
2016-07-11 21:58
627 查看
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/jb51.net/tomcat/就是我想设置的网站根目录,然后重启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>
这样就可以了。
找到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/jb51.net/tomcat/就是我想设置的网站根目录,然后重启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>
这样就可以了。
相关文章推荐
- Tomcat做推送服务引出的对TCP协议的调优
- Tomcat异常页面处理
- Tomcat7图形界面管理
- tomcat7启动服务内存溢出
- 【Jenkins】包含dubbo服务的war包自动部署tomcat
- Jconsole监控tomcat 的JVM内存的设置
- 将myeclipse项目import到eclipse无法部署到tomcat中
- 为什么Tomcat的webapps目录下新建的目录不能访问html文件?
- 加载tomcat下的属性文件
- MyEclipse8.5 环境中配置Tomcat7.X
- Tomcat部署Maven项目后报错A child container failed during start
- Ubuntu 把Tomcat8 设置成系统服务
- eclipse启动tomcat后localhost:8080无法访问问题
- Server MyEclipse Tomcat v7.0 was unable to start within 45 seconds. If the server requires more time
- java.lang.UnsatisfiedLinkError: D:\Tomcat\apache-tomcat-7.0.37\bin\tcnative-1.dll: Can't load AMD 64
- Tomcat服务器配置参考
- Tomcat的目录结构及用途
- MyEclipse2015+Tomcat+MAVEN+SVN项目环境搭建
- tomcat常用配置详解
- 隐藏tomcat命令窗口的方法