一監(jiān)聽(tīng)器Listener
1 什么是監(jiān)聽(tīng)器
主要用來(lái)監(jiān)聽(tīng)特定對(duì)象的創(chuàng)建、銷(xiāo)毀、屬性的變化
2 監(jiān)聽(tīng)器分類(lèi)
ServletContext、HttpSession肛根、ServletRequest
(1)監(jiān)聽(tīng)對(duì)象創(chuàng)建/銷(xiāo)毀的監(jiān)聽(tīng)器接口
ServlectContxtListener
ServletRequestListener
HttpSessionListener
com.rr.listener.MyContextListener
(2)監(jiān)聽(tīng)對(duì)象屬性變化的接口
監(jiān)聽(tīng)屬性的增刪改
ServletContextAttributeListener
ServletRequestAttributeListener
HttpSessionAttributeListener
(3)其他session相關(guān)監(jiān)聽(tīng)器接口(了解)
HttpSessionBindingListener 監(jiān)聽(tīng)對(duì)象綁定到session的事件
HttpSessionActivationListener 監(jiān)聽(tīng)session的序列化和反序列化
練習(xí):在線用戶提示
用一個(gè)列表存儲(chǔ)用戶信息辫塌,用戶登錄漏策,將用戶名添加到列表中;用戶退出登錄臼氨,將用戶名從列表中刪掉