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中删除。

  • 相关阅读:
    上海python14期第一次周考
    day05总结
    day05作业
    day04总结
    js判断是安卓还是Ios
    移动端 --- 阻止浏览器点击图片会预览的方法
    meta标签禁止打电话 转载
    mac 常用命令
    ajax. 通过后台接口 渲染数据
    vue prop
  • 原文地址:https://www.cnblogs.com/huangfox/p/2222717.html
Copyright © 2011-2022 走看看