Java中的八大监听器

ServletContext域

1、生命周期监听接口:ServletContextListener

①contextInitialized(ServletContextEvent sce) 创建ServletContext时调用

②contextDestroyed(ServletContextEvent sce) 销毁ServletContext时调用

2、属性监听接口:ServletContextAttributeListener

①attributeAdded(ServletContextAttributeEvent scae) 添加属性时调用

②attributeRemoved(ServletContextAttributeEvent scae) 移除属性时调用

③attributeReplaced(ServletContextAttributeEvent scae) 修改属性时调用

HttpSession域

3、生命周期监听接口:HttpSessionListener

①sessionCreated(HttpSessionEvent se) 创建session时调用

②sessionDestroyed(HttpSessionEvent se) 销毁session时调用

4、属性监听接口:HttpSessionAttributeListener

①attributeAdded(HttpSessionBindingEvent se) 添加属性时调用

②attributeRemoved(HttpSessionBindingEvent se) 移除属性时调用

③attributeReplaced(HttpSessionBindingEvent se) 修改属性时调用

ServletRequest域

5、生命周期监听接口:HttpSessionListener

①requestInitialized(ServletRequestEvent sre) 创建request时调用

②requestDestroyed(ServletRequestEvent sre) 销毁request时调用

6、属性监听接口:HttpSessionAttributeListener

①attributeAdded(ServletRequestAttributeEvent srae) 添加属性时调用

②attributeRemoved(ServletRequestAttributeEvent srae) 移除属性时调用

③attributeReplaced(ServletRequestAttributeEvent srae) 修改属性时调用

 

7、感知监听接口:HttpSessionBindingListener

实现了HttpSessionBindingListener接口的JavaBean对象可以感知自己被绑定到Session中和从 Session中删除的事件,不需要在web.xml注册

①valueBound(HttpSessionBindingEvent event) 对象绑定到session时调用

②valueUnbound(HttpSessionBindingEvent event) 对象从session中删除时调用

8、HttpSessionActivationListener:钝化、活化监听器

实现了HttpSessionActivationListener接口的JavaBean对象可以感知自己被活化(反序列化)和钝化(序列化)的事件,不需要在web.xml注册

①sessionDidActivate(HttpSessionEvent se)

②sessionWillPassivate(HttpSessionEvent se)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值