Usage of load-on-startup in web.xml

xiaoxiao2021-03-06  156

Servlet specification explained on load-on-startup of: The load-on-startup element indicates that this servlet should be loaded (instantiated and have its init () called) on the startup of the web application The optional contents of these element. must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load- ON-Start-Up Value.

The load-on-startup option has the following attention in Web.xml:

1. Load-on-startup indicates that the specified servlet is executed when the application starts, the lower the number in load-on-startup, the earlier startup. More useful is org.apache.struts.Action.actionServlet in Struts, for example:

Action

Org.apache.struts.Action.ActionServlet

Config

/Web-inf/struts-config.xml

Debug

2

Application

ApplicationResources

2

There is also like using the Proxool configuration connection pool, etc., you need to start when starting.

2. Load-on-startup specified servlet is officially launched after execution. Otherwise, the application cannot be accessed before the servlet has been successfully processed.

转载请注明原文地址:https://www.9cbs.com/read-127895.html

New Post(0)