zoukankan      html  css  js  c++  java
  • 【JavaEE企业应用实战学习记录】MyGetAttributeListener

     1 package sanglp.servlet;
     2 
     3 import javax.servlet.ServletContext;
     4 import javax.servlet.ServletContextAttributeEvent;
     5 import javax.servlet.ServletContextAttributeListener;
     6 import javax.servlet.annotation.WebListener;
     7 
     8 /**
     9  * Created by Administrator on 2016/10/5.
    10  * 监听ServletContext范围内属性改变的Listener
    11  */
    12 @WebListener
    13 public class MyServletContextAttributeListener implements ServletContextAttributeListener {
    14 
    15     @Override
    16     public void attributeAdded(ServletContextAttributeEvent servletContextAttributeEvent) {
    17         ServletContext application=servletContextAttributeEvent.getServletContext();
    18         //获取添加的属性名和属性值
    19         String name=servletContextAttributeEvent.getName();
    20         Object value=servletContextAttributeEvent.getValue();
    21         System.out.println(application+"范围内添加了"+name+"值为"+value+"的属性");
    22 
    23 
    24     }
    25 
    26     @Override
    27     public void attributeRemoved(ServletContextAttributeEvent servletContextAttributeEvent) {
    28         ServletContext application=servletContextAttributeEvent.getServletContext();
    29         //获取添加的属性名和属性值
    30         String name=servletContextAttributeEvent.getName();
    31         Object value=servletContextAttributeEvent.getValue();
    32         System.out.println(application+"范围内删除了"+name+"值为"+value+"的属性");
    33     }
    34 
    35 
    36     @Override
    37     public void attributeReplaced(ServletContextAttributeEvent servletContextAttributeEvent) {
    38         ServletContext application=servletContextAttributeEvent.getServletContext();
    39         //获取添加的属性名和属性值
    40         String name=servletContextAttributeEvent.getName();
    41         Object value=servletContextAttributeEvent.getValue();
    42         System.out.println(application+"范围内替换了"+name+"值为"+value+"的属性");
    43 
    44     }
    45 }
  • 相关阅读:
    3.2.1 正則表達式的语法(1)
    朴素贝叶斯(naive bayes)
    有方向的运动js
    碰撞检測之OBB-OBB的SweepTest
    左右上下都能滚动的效果
    C语言中 fputs() fgets() 的使用方法
    Apache Module mod_ssl
    "ssllabs" website and "testssl" website
    Google发布SSLv3漏洞简要分析报告
    为什么要使用TLSv1.2和System SSL?
  • 原文地址:https://www.cnblogs.com/dream-to-pku/p/5933220.html
Copyright © 2011-2022 走看看