(Transfer) web.xml in the load-on-startup function

2010-06-09  来源:本站原创  分类:Java  人气:156 

On the web.xml in the load-on-startup function
load-on-startup element in the web application starts when the specified servlet is loaded in the order, if greater than 0
Configuration when the container load and initialize the servlet, the priority is based on load-on-startup value to set the value higher the priority of small

<servlet-name> initservlet </ servlet-name>
<servlet-class> com.royzhou.util.initServlet </ servlet-class>
<load-on-startup> 5 </ load-on-startup>
</ Servlet>

For example: Here's <load-on-startup> 5 that load the servlet and the class is initialized, the initialization is generally called the init method of this class

For instance, we can define in our application and then some static constants in this servlet's init method do initialization. Or write to the properties file, or configuration file read program.