• 监听器


    一、监听器:主要是用来监听特定对象的创建或销毁、属性的变化;是一个实现特定接口的普通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)

    五、统计在线人数。实战

  • 相关阅读:
    Vue 导出excel 自适应宽度
    .Net 5.0 项目数据库连接字符串
    .Net 5.0 从api下载文件到本地
    Oracle for 循环输出(游标提取)
    找到多个与名为“Home”的控制器匹配的类型
    让tomcat使用指定JDK
    .NetCore 3 单文件发布详解
    CentOS7 常用命令大全
    阿里云ECS CentOS 7.8 安装图形化桌面GNOME
    用命令禁用本地连接
  • 原文地址:https://www.cnblogs.com/h-g-f-s123/p/6344919.html
Copyright © 2020-2023  润新知