阿迪.Java

我开始练习 从容地前进 优雅地转身 并保持冷静思考的模样

web.xml中load-on-startup的用法

Servlet specification中关于load-on-startup的解释:
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 choosesIf 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.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

load-on-startup选项在web.xml中有以下几个注意点:

1. load-on-startup表明在应用程序启动的时候执行指定的servlet,load-on-startup中的数字越低表明启动越早。比较有用的是Struts中的org.apache.struts.action.ActionServlet,例如:

 
    action
    org.apache.struts.action.ActionServlet
   
      config
      /WEB-INF/struts-config.xml
   
   
      debug
      2
   
   
      application
      ApplicationResources
   
    2
 

  还有像使用proxool配置连接池等,都需要在启动时启动。

2. load-on-startup指定的servlet在执行后,应用程序才正式启动。否则,在servlet未成功处理前,无法访问应用程序。

阅读更多
个人分类: Java
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭