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

    (1)ServletContextListener监听器

      在ServletContext创建和关闭时,都会通知ServletContextListener监听器

      常用方法如下:

    方法声明 功能介绍
    void contextInitialized(ServletContextEvent sce) 当ServletContext创建的时候,将会调用这个方法
    void contextDestroyed(ServletContextEvent sce) 当ServletContext销毁的时候(例如关闭应用服务器 或者重新加载应用),将会调用这个方法

    例子:

     

     效果:
      启动服务器时:

       停止服务器时:

    (2)ServletContextAttributeListener监听器

      向ServletContext添加、删除或者替换一个属性的时候,将会通知

      ServletContextAttributesListener监听器

      常用方法如下:

    方法声明 功能介绍
    void attributeAdded(ServletContextAttributeEvent scae) 往ServletContext中加入一个属性的时 候触发
    void attributeRemoved(ServletContextAttributeEvent scae) 从ServletContext中删除一个属性的时 候触发
    void attributeReplaced(ServletContextAttributeEvent scae) 改变ServletContext中属性的时候触发

    例子:

     

     

     效果:
      启动服务器,访问contextAttribute.jsp:

  • 相关阅读:
    python os模块汇总
    python xlsxwriter使用方法汇总
    python 虚拟环境生成requirements.txt 和利用requirements.txt批量安装
    python 中将大列表拆分成小列表
    python print的用法
    python学习
    浮躁
    在线绘图工具
    开通园子
    iOS拓展---(APP)进程间常用通信方式总结
  • 原文地址:https://www.cnblogs.com/JasperZhao/p/15403089.html
Copyright © 2011-2022 走看看