zoukankan      html  css  js  c++  java
  • Servlet总结05——servlet监听器

    servlet监听的对象:

    它负责监听ServletContext、HttpSession、ServletRequest对象的生命周期时间,以及属性改变事件。
     

    Servlet监听器的作用:

    用于监听一些重要事件的发生,监听器对象可以在事情发生前、发生后可以做一些必要的处理。
     

    目前Servlet2.4和JSP2.0总共有8个监听器接口和6个Event类,其中HttpSessionAttributeListener与
    HttpSessionBindingListener皆使用HttpSessionBindingEvent;HttpSessionListener和HttpSessionActivationListener则都使用HttpSessionEvent;其余Listener对应的Event如下所示:

    Listener接口

    Event

    ServletContextListener

    ServletContextEvent

    ServletContextAttributeListener

    ServletContextAttributeEvent

    HttpSessionListener

    HttpSessionEvent

    HttpSessionActivationListener

    HttpSessionAttributeListener

    HttpSessionBindingEvent

    HttpSessionBindingListener

    ServletRequestListener

    ServletRequestEvent

    ServletRequestAttributeListener

    ServletRequestAttributeEvent

     

    注意:

    HttpSessionAttributeListener与HttpSessionBindingListener的主要区别是:

    HttpSessionAttributeListener——用于监听session中何时添加、删除或替换了某种类型的属性;

    HttpSessionBindingListener——由属性自身来实现,以便属性知道它什么时候被添加到一个session中,或者什么时候从session中删除。

  • 相关阅读:
    ☀【CSS3】形状
    ♫【MV*】
    ☀【布局】多栏布局 / 盒布局
    2017 无奈的模拟赛 1
    洛谷——P2093 零件分组
    洛谷——P1209 [USACO1.3]修理牛棚 Barn Repair
    洛谷——P2695 骑士的工作
    洛谷——P1330 封锁阳光大学
    python(16)- python内置函数
    MTK平台缩写
  • 原文地址:https://www.cnblogs.com/huangfox/p/2222717.html
Copyright © 2011-2022 走看看