welcome-file-list
在web.xml
文件中的web-app
块的welcome-file-list
子元素用于定义欢迎文件列表。 它的子元素是welcome-file
,用于定义默认打开的页面。
默认情况下,服务器按以下顺序查找欢迎文件:
web.xml
文件中的welcome-file-list
指定的文件- index.html
- index.html
- index.jsp
如果没有找到这些文件,服务器会报告404错误。
如果在web.xml
中指定了welcome-file
,并且所有文件index.html
,index.html
和index.jsp
都存在,那么优先级将转到welcome-file
。
如果web.xml
文件中不存在welcome-file-list
项,那么优先级到index.html
文件,然后是index.html
,以及最后是index.jsp
文件。
load-on-startup
如果load-on-startup
元素值为正,则会在Web应用程序部署或服务器启动时加载servlet。 它也被称为servlet的预初始化。
<servlet>
<servlet-name>com.my</servlet-name>
<servlet-class>MyServlet1</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<servlet-name>com.yiibai.BServlet</servlet-name>
<servlet-class>Myservlet2</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
先加载MyServlet1,再加载Myservlet2,如果load-on-startup
元素为负值,则此servlet将请求时第一个加载。