首页 > 其他 > 详细

监听器

时间:2017-01-23 21:34:49      阅读:215      评论:0      收藏:0      [点我收藏+]

一、监听器:主要是用来监听特定对象的创建或销毁、属性的变化;是一个实现特定接口的普通java类。

二、servlet中哪些对象需要监听?

  request/session/servletContext

  分别对应,request监听器、session相关的监听器、servletContext监听器。

三、监听器的接口

(1)监听对象的创建/销毁

   Interface ServletRequestListener     监听request对象的创建或销毁

         Interface HttpSessionListener         监听session对象的创建或销毁

         Interface ServletContextListener     监听servletContext对象的创建或销毁

(2)监听对象属性的变化

     Interface ServletRequestAttributeListener  监听request对象属性变化: 添加、移除、修改

         Interface HttpSessionAttributeListener      监听session对象属性变化: 添加、移除、修改

   Interface ServletContextAttributeListener   监听servletContext对象属性变化

(3) session相关监听器

   Interface HttpSessionBindingListener             监听对象绑定到session上的事件    

        Interface HttpSessionActivationListener(了解)  监听session序列化及反序列化的事件

四、监听器的开发步骤

  (1)编写普通java类,实现相关的接口

  (2)配置(web.xml)

五、统计在线人数。实战

 

监听器

原文:http://www.cnblogs.com/h-g-f-s123/p/6344919.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!