码迷,mamicode.com
首页 > 其他好文 > 详细

监听器

时间:2017-05-27 21:15:52      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:tde   initial   request   create   des   http   cti   moved   ini   

servlet一共提供了三个类型的监听器类;

分别对request、session、application三个作用域对象进行监听。需要在web.xml文件中配置监听器;

request对象的监听器有两个类

ServletRequestListener 类 监听request对象创建、销毁。

      requestInitialized 监听request对象创建的方法;

      requestDestroyed 监听rquest对象销毁的方法。

ServletRequestAttributeListener类, 监听request对象属性值增删改;

      attributeAdded 监听request作用域对象新增一个属性值

      attributeRemoved 监听request作用域对象删除一个属性

      attributeReplaced 监听request作用域对象修改(替换)一个属性值

 

session对象的监听器有4个类

HttpSessionListener 类 监听session创建、销毁;

       sessionCreated 监听session创建的方法

       sessionDestroyed 监听sessioin销毁的方法

HttpSessionAttributeListener 类 监听session属性值增删改;

       attributeAdded 新增session属性值的方法

       attributeRemoved 删除session属性值的方法

       attributeReplaced 修改(替换)session属性值的方法

HttpSessionActivationListener session对象的迁移监听

HttpSessionBindingListener session对象的绑定监听(此监听器不需要web配置)

 

application对象的监听器有2个类

ServletContextListener 类 监听application对象创建、销毁;

    contextInitialized 创建application对象的方法

    contextDestroyed 销毁appclication对象的方法

ServletContextAttributeListener 类 监听application对象属性值增删改;

     attributeAdded 新增application属性值的方法

     attributeRemoved 删除application属性值的方法

     attributeReplaced 修改(替换)application属性值的方法

 

监听器

标签:tde   initial   request   create   des   http   cti   moved   ini   

原文地址:http://www.cnblogs.com/ziranfengwei/p/6914375.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!