首页 > 代码库 > 【JavaEE企业应用实战学习记录】MyGetAttributeListener
【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范围内属性改变的Listener11 */12 @WebListener13 public class MyServletContextAttributeListener implements ServletContextAttributeListener {14 15 @Override16 public void attributeAdded(ServletContextAttributeEvent servletContextAttributeEvent) {17 ServletContext application=servletContextAttributeEvent.getServletContext();18 //获取添加的属性名和属性值19 String name=servletContextAttributeEvent.getName();20 Object value=http://www.mamicode.com/servletContextAttributeEvent.getValue();21 System.out.println(application+"范围内添加了"+name+"值为"+value+"的属性");22 23 24 }25 26 @Override27 public void attributeRemoved(ServletContextAttributeEvent servletContextAttributeEvent) {28 ServletContext application=servletContextAttributeEvent.getServletContext();29 //获取添加的属性名和属性值30 String name=servletContextAttributeEvent.getName();31 Object value=http://www.mamicode.com/servletContextAttributeEvent.getValue();32 System.out.println(application+"范围内删除了"+name+"值为"+value+"的属性");33 }34 35 36 @Override37 public void attributeReplaced(ServletContextAttributeEvent servletContextAttributeEvent) {38 ServletContext application=servletContextAttributeEvent.getServletContext();39 //获取添加的属性名和属性值40 String name=servletContextAttributeEvent.getName();41 Object value=http://www.mamicode.com/servletContextAttributeEvent.getValue();42 System.out.println(application+"范围内替换了"+name+"值为"+value+"的属性");43 44 }45 }
【JavaEE企业应用实战学习记录】MyGetAttributeListener
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。