web.xml里面的welcome-file-list是什么意思

来源:互联网 发布:进入数据库的命令 编辑:程序博客网 时间:2024/05/21 15:18

为了解决在eclipse打开工程里面随意一个网页都能正常显示时,写过的页面都要加进web.xml的welcome-file-list里面,例如

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>buy31-35.html</welcome-file>
        <welcome-file>favorite.html</welcome-file>
        <welcome-file>MyFavorite.html</welcome-file>
        <welcome-file>payFail.html</welcome-file>
        <welcome-file>PayIt.htm</welcome-file>
        <welcome-file>paysucess.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

表示里面含有index.jsp、buy31-35.html等页面,运行工程时默认显示顺序第一的页面,在这里面也就是index.jsp页面。

如果:

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

里面没有把buy31-35.html加进去,即使工程里面含有这个页面,运行此页面时也是不能打开的,打开的只能是默认的index.jsp页面。



另外 index.jsp我们一般都是删掉,重新新建自己的html或者是jsp等页面,这里index.jsp其实有一个作用,index.jsp页面是和WebRoot同级的,我们新建页面时一般习惯也和WebRoot同级,其实这样不安全,这样容易被人家发现源代码,为了保护源代码,可以把自己写的页面放进Web-INF下,意思页面的信息,是不允许别人看到的。这样在index.jsp里的body还要加一个设置<jsp:forward page="buy31-35.html"></jsp:forward>意思是index.jsp跳转到自己写的buy31-35.html页面。

0 0
原创粉丝点击