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

  • 相关阅读:
    二叉树操作
    jQuery下拉列表插件 jQselectable
    DeDeCMS常用标签代码整理汇总
    用DEDECMS做手机网站
    DedeCMS模板文件结构
    用aspnet_compiler编译(发布)网站
    把网站提交到搜索引擎
    jGrowl 制作消息弹出框
    关于标签 XUACompatible
    jQuery下拉框插件 FlexBox
  • 原文地址:https://www.cnblogs.com/huangfox/p/2222717.html
Copyright © 2020-2023  润新知