Java Listener
来源:互联网 发布:c windows.h 编辑:程序博客网 时间:2024/05/22 07:07
第1章 Listener监听器
1.1 Listener对象分类
Servlet的Listener监听器包括三种类型:
1、ServletContextListener 监听ServletContext对象
- publicvoid contextInitialized(ServletContextEvent event);
- publicvoid contextDestoryed(ServletContextEvent event);
2、HttpSessionListener 监听Session对象
- publicvoid sessionCreated(HttpSessionEvent event);
- publicvoid sessionDestoryed(HttpSessionEvent event);
1、 HttpRequestListener 监听Request对象
- publicvoid requestinitialized(ServletRequestEvent event);
- publicvoid requestDestoryed(ServletRequestEvent event);
Web.xml文件配置
- <listener>
- <listener-class>listener.MyListener</listener-class>
- </listener>
1.2 Listener按属性分类
按照监听事件类型划分分为如下类型:
1、 用于监听域对象自身的创建和销毁的事件监听器。
2、 用于监听域对象的属性的增加和删除的事件监听器。
3、 用于监听绑定到HttpSession域中的某个对象的状态的事件监听器。
1.2.1 监听对象的属性事件监听器接口
1、 attributeAdd当被监听域对象中增加属性时会调用该系列监听器
- publicvoid attributeAdded(ServletContextAttributeEvent event);
- publicvoid attributeAdded(HttpSessionBindingEvent event);
- publicvoid attributeAdded(ServletRequestAttributeEvent event);
2、 attributeRemoved当被监听域对象中删除属性时会调用该系列监听器
- publicvoid attributeRemoved(ServletContextAttributeEvent event);
- publicvoid attributeRemoved(HttpSessionBindingEvent event);
- publicvoid attributeRemoved(ServletRequestAttributeEvent event);
3、 attributeReplaced当被监听域对象中属性变更时时会调用该系列监听器
- publicvoid attributeReplaced(ServletContextAttributeEvent event);
- publicvoid attributeReplaced(HttpSessionBindingEvent event);
- publicvoid attributeReplaced(ServletRequestAttributeEvent event);
注:使用属性监听器需要继承如下接口,实现以上方法
- ServletContextAttributeListener,
- HttpSessionAttributeListener,
- ServletRequestAttributeListener
1.2.2 感知Session绑定的事件监听器
保存到Session域中的对象可以有多种状态:
1、 绑定到Session域中
2、 从Session域中解除绑定
3、 Session对象持久化到存储设备
4、 Session对象从一个存储设备中恢复
可以使用
- HttpSessionBindingListener、HttpSessionActivationListener
两个监听接口实现JavaBean对象的绑定,从而了解JavaBean对象在Session域的状态。
- HttpSessionBindingListener
- publicvoid valueBound(HttpSessionBindingEvent event);
- publicvoid valueUnbound(HttpSessionBindingEvent event);
- HttpSessionActivationListener
- publicvoid sessionWillPassivate(HttpSessionEvent event);
注:当Session对象持久化到文件系统时,激活上面方法。
- publicvoid sessionDidActivate(HttpSessionEvent event);
注:当Session对象从文件系统恢复时,激活上面方法。
- Java Listener
- Java Listener模式
- Java Listener 模式
- Java Listener 模式
- java web listener 监听器
- Java Listener 模式
- Java监听器Listener
- java filter servlet listener
- Java监听器Listener使用说明
- Java Listener 模式
- Java Listener 模式
- Java EE中Listener
- java web listener 监听器
- java中的监听器(listener)
- Java Web监听器Listener
- java servlet listener
- Java Listener 模式
- java web listener 监听器
- 应用汇不知道,金山安全套装不知道,卡巴知道
- 分组背包
- datatable 字段值 变成 string字符串
- php 执行时间
- 关于 SubMenu
- Java Listener
- linq 多条件组织查询核心代码
- MVC模式已死?何不试试MOVE
- POJ 1208 The Blocks Problem (UVA 101)
- 使用反射执行效率测试-1
- Vbox使用点滴
- Apache Configuration
- js获取<select>下拉菜单的value值和text值
- uC/OS-II内存管理函数的二维指针