• 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)

  • 相关阅读:
    剑指offer字符串列表
    剑指offer数组3
    剑指offer数组2
    剑指offer数组1
    剑指offer数组列表
    tensorflow+ssd_mobilenet实现目标检测的训练
    Win7+keras+tensorflow使用YOLO-v3训练自己的数据集
    Java是如何实现跨平台的
    Xshell 、PuTTY 复制文件到Linux
    Asp.Net Core2.0在linux下发布
  • 原文地址:https://www.cnblogs.com/the-wang/p/7536103.html
Copyright © 2020-2023  润新知