日期:2014-05-18  浏览次数:20985 次

更改tomcat默认主页问题 试了N次 但我还是失败了
我的设置步骤如下:
(1)在c:\tomcat\webapps\目录下新建web文件夹,web中有我自己写的index.html
和index.jsp;
(2)在c:\tomcat\conf\server.xml   文件中
<Host   ...>
    ....
    ....
    ....
</Host>  标记更改为:
<Host   name= "localhost "   debug= "0 "   appBase= "web "
              unpackWARs= "true "   autoDeploy= "true "
              xmlValidation= "false "   xmlNamespaceAware= "false ">
   ....
            ....
            ....
          <Context   path= " "   docBase= "web "   debug= "0 "   reloadable= "true "   />
</Host>
(3)在c:\tomcat\conf\web.xml   文件不做更改.因为web中的文件名为:index.jsp;
重起tomcat,键入http://localhost:8080   IE仍然显示默认页面.
接下来我该怎么办呢?


------解决方案--------------------
在web.xml中添加 <welcome-file-list>
<welcome-file> index.jsp </welcome-file>
<welcome-file> index.html </welcome-file>
<welcome-file> index.htm </welcome-file>
</welcome-file-list>
------解决方案--------------------
1.在c:\tomcat\webapps\web\WEB-INF\web.xml中添加
<welcome-file-list>
<welcome-file> index.jsp </welcome-file>
<welcome-file> index.html </welcome-file>
<welcome-file> index.htm </welcome-file>
</welcome-file-list>
就是楼上说的.注意上面三个文件的顺序,把index.jsp放在第一个,才能优先显示index.jsp.

2.你的host元素的appBase属性设置错了,在
<Host name= "localhost " debug= "0 " appBase= "web "
unpackWARs= "true " autoDeploy= "true "
xmlValidation= "false " xmlNamespaceAware= "false ">
中将appBase= "web "改成appBase= "c:\tomcat\webapps "

------解决方案--------------------
新建XML文件,文件名为ROOT.xml(注意大小写),内容为:
<Context path= " " docBase= "D:\jsp ">
</Context>
放到TOMCAT\conf\Catalina\localhost\目录下,就OK了,最好不要改server.xml,因为它是服务器的主要配置文件,配置错误的话,整个TOMCAT都会无法启动或者出错。
------解决方案--------------------
呵呵 Host写错了
Context中的docBase属性是相对于Host中的appBase来说的,当然也可以是绝对路径
appBase最后改为webapps
呵呵 当初我也搞了不少时间 难者不会 会者不难啊