“嘿,每当您收到目录请求时,请查看是否存在./index.jsp并将其显示给用户。”
那正是welcome-file-list
应该做的。
只需将以下内容添加到web.xml。在这种情况下,首先容器将尝试index.html
,如果不存在,则将尝试index.jsp
。
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
我已经在Tomcat 5.5上对其进行了测试,并且可以正常工作。
不幸的是,真的很难找到web.xml的官方参考。因此,这里是Oracle Weblogic的文档。我认为这是可以信任的…