Reprinted blog: http://www.blogjava.net/xzclog/archive/2011/09/29/359789.html
The following configuration, familiar with DWR is familiar:
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
We notice that it contains this configuration: <load-on-startup>1</load-on-startup> So what does this configuration do?
an explanation of the original English is as follows:
Servlet Specification:
The load-on-startup element indicates, this servlet should is loaded (Instantiated and has its init () called
The meaning of the translation comes roughly as follows:
1) The Load-on-startup element flags whether the container loads the servlet at startup (instantiating and invoking its init () method).
2) Its value must be an integer indicating the order in which the servlet should be loaded
2) A value of 0 or greater than 0 o'clock indicates that the container loads and initializes the servlet when the application is started;
3) When the value is less than 0 or unspecified, the container will not load until the servlet is selected.
4) The lower the value of a positive number, the higher the precedence of the servlet, and the more loaded it will be when the app starts.
5) At the same time, the container will be loaded in its own order of choice.
So, <load-on-startup>x</load-on-startup>, the value 1,2,3,4,5 in X represents the priority, not the start delay time.
The following topics:
What definitions are not included in 2.web.xml (multiple selection)
A. default start Page
B.servlet Start delay time definition
C.error Processing Page
Reload time after d.jsp file changes
Answer:b,d
Most servlets are usually created and initialized by the application server when the user first requests it, but <load-on-startup>n</load-on-startup> can be used to change the situation. Change the priority of loading according to your needs!
The role of Load-on-startup in Web. xml