假如用户提供了一个像http://host/webAppPrefix/directoryName/ 这样的包含一个目录名但没有包含文件名的URL,会发生什么事情呢?用户能得到一个目录表?一个错误?还是标准文件的内容?如果得到标准文件内容,是index.html、index.jsp、default.html、default.htm或别的什么东西呢?
Welcome-file-list元素及其辅助的welcome-file元素解决了这个模糊的问题。例如,下面的web.xml项指出,如果一个URL给出一个目录名但未给出文件名,服务器应该首先试用index.jsp,然后再试用index.html。如果两者都没有找到,则结果有赖于所用的服务器(如一个目录列表)。
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
虽然许多服务器缺省遵循这种行为,但不一定必须这样。因此,明确地使用welcom-file-list保证可移植性是一种良好的习惯。

解决方案 »

  1.   

    谢谢,在web.xml里找不到<welcome-file-list>标签,不过有下面的代码,上网查了是表单身份验证方式,应该就是这段转到logon.jsp的。    <login-config>
            <auth-method>FORM</auth-method>
            <realm-name>file</realm-name>
            <form-login-config>
                <form-login-page>/logon.jsp</form-login-page>
                <form-error-page>/logonError.jsp</form-error-page>
            </form-login-config>
        </login-config>