zoukankan      html  css  js  c++  java
  • Servlet监听器

    Servlet API2.3以后提供了以下监听器接口(8种)

    1. ServletContextListener 应用上下文生命周期监听器(整个程序)
    2. ServletConextAttributeListener 应用上下文属性监听器
    3. ServletRequestListener 请求属性事件监听器
    4. ServletRequestAttrbuteListener请求属性事件监听器
    5. HttpSessionListener会话生命周期监听器
    6. HttpSessionActivationListener会话激活和钝化事件监听器
    7. HttpSessionAttributListener会话属性事件监听器
    8. HttpSessionBindingListener会话值绑定事件监听器

      创建步骤:

    1. 创建一个实现监听器接口的类
    2. 配置web.xml文件 注册监听器

    监听器的启动顺序:按照web.xml的配置顺序来启动

    加载顺序:监听器>过滤器>Servlet

    常用的监听器接口:

    监听HttpSession的操作:

           当创建一个Session时,   sessionCreated(SessionEvent se)

           当销毁一个Session时,   sessionDestroyed(HttpSessionEvent se)

    监听HttpSession中属性的操作

           当Session 增加一个属性时, attributeAdded(HttpSessionBindingEvent se)

           当Session 删除一个属性时,  attributeRemove(HttpSessionBindingEvent se)

           当Session 属性被重新设置时, attributeReplaced(HttpSessionBingEvent se)

  • 相关阅读:
    crash reporting system for Windows applications
    1
    qt 试用 (3)配置编译源代码及调试
    kd tree & ray tracing
    new
    KMP算法中关于next数组的探究
    teamviewer vs echovnc
    NAT之stun确定nat类型
    Wireshark
    GNU httptunnel,当SSH被block时的选择
  • 原文地址:https://www.cnblogs.com/the-wang/p/7536103.html
Copyright © 2011-2022 走看看