web程序首页配置

来源:互联网 发布:淘宝直通车如何出价 编辑:程序博客网 时间:2024/04/30 05:36

使用Tomcat容易默认首页为index.html,index.jsp,index.htm

即使我们工程中WEB-INF/web.xml中并没有设置welcome-file。

因为Tomcat的安装文件中默认就设置了这三个页面,路径:D:\apache-tomcat-7.0.67\conf\web.xml 文件结尾处

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>


一、当我们在server.xml中,直接指定域名时,通过spring指定的首页会生效。不会去访问index.html

<Host name="a.com" appBase="/Data/WEB_APP.01/a.com" unpackWARs="true" autoDeploy="true">
                <Context path="" docBase="ROOT" workDir="/Data/WEB_APP.01/work/a.com"/>
</Host>


二、可是当使用端口和IP方式时,通过spring指定的首页不会生效。会访问index.html

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

 </Host>

这样会第二种方式导致存在一个问题。若webapp目录下有index.html,通过域名访问会直接访问index.html页面,而不是通过spring配置的首页跳转。

spring框架设置的跳转如下:

    <!-- 配置默认首页 -->
    <mvc:view-controller path="/" view-name="redirect:/page/redirect"/>


本来是想设置index.html为一个测试页面,用来验证服务器是否启动成功。这种问题存在于首页不是index.html的项目

这个问题的原因还没有找到,与大家一起分享下。

0 0
原创粉丝点击