Java学习路线-50:Servlet监听器Listener
课时12 什么叫监听器Listener AWT、SAX 监听器: 一个接口,内容由用户实现 需要注册 监听器中的方法,会在特殊事件发生时被调用 观察者 事件源 事件 监听器 课时13 监听器概述以及生命周期监听器 事件源 1 、ServletContext 生命周期监听 ServletContextListener 创建 contextInitialized 销毁 contextDestroyed ServletContextEvent - getServletContext ( ) 属性监听 ServletContextAttributeListener 添加 attributeAdded 替换 attributeReplaced 移除 attributeRemoved ServletContextAttributeEvent - getName ( ) - getValue ( ) 2 、HttpSession 生命周期监听 HttpSessionListener 创建 sessionCreated 销毁 sessionDestroyed HttpSessionEvent - getSession ( ) 属性监听 HttpSessionAttributeListener 添加 attributeAdded 替换 attributeReplaced 移除