如果开发人员没有在WEB-IF/web.xml文件中定义网站的默认主页,那么在用户仅输入网站主目录的URL(如http://host/WebAppPrefix/)访问页面的时候,默认主页将依赖服务器默认主页文件配置,比如index.jsp. 如果希望index设置为默认主页名称,建议开发人员在网站配置文件web.xml中明确定义一个welcome-file-list的标签。
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
虽然在默认情况下,许多服务器会执行以上行为,但是它们并不是必须这么做。所以,最好显式使用welcome-file-list来确保应用程序的可移植性。