ServletContextListener: 此接口的实现类获得有关他们的一部分更改Web应用程序的servlet上下文通知。要接收通知事件,实现类必须为Web应用程序的部署描述符中进行配置。(web.xml中)
是全局的servlet容器监听 ,当容器加载web程序的时候会调用它的initialized方法 (ServletContextListener)
contextInitialized(ServletContextEvent e
);
通知Web应用程序的初始化过程已开始。所有ServletContextListeners通知上下文初始化在web应用程序的任何过滤器或servlet初始化之前
contextDestroyed(ServletContextEvent e
);
通知servlet上下文即将关闭。所有的servlet和过滤器已经destroy()了。在任何ServletContextListeners通知上下文销毁之前
/**
** Notification that the servlet context is about to be shut down. All
* servlets and filters have been destroy()ed before any
* ServletContextListeners are notified of context destruction.
*/
一般处理全局的信息初始化跟销毁
--------------------------
ServletContextEvent:
这是通知有关更改Web应用程序的servlet上下文(servletContext)的事件类
----------------------------------
当向application域中增加或者移除对象的时候 这个监听器 ServletContextAttributeListener 会起作用
attributeAdded() attributeReplaced()、attributeRemoved()