zoukankan      html  css  js  c++  java
  • 监听域对象的属性变更

    今天来个对监听对象的小测试

    public class MyBean implements HttpSessionBindingListener,
            HttpSessionActivationListener, Serializable {
    
        @Override
        public void sessionDidActivate(HttpSessionEvent arg0) {
            System.out.println("对象从文件系统中恢复了");
    
        }
    
        @Override
        public void sessionWillPassivate(HttpSessionEvent arg0) {
            System.out.println("对象将被持久化到文件系统中");
    
        }
    
        @Override
        public void valueBound(HttpSessionBindingEvent hbe) {
            System.out.println("当前Session的ID标识为"+hbe.getSession().getId());
            System.out.println("对象被绑定到这个Session对象中的"+hbe.getName());
            
    
        }
    
        @Override
        public void valueUnbound(HttpSessionBindingEvent hbe) {
            System.out.println("当前Session的id为"+hbe.getSession().getId());
            System.out.println("对象从这个Session对象中的"+hbe.getName()+"属性上解除可绑定");
    
        }
    
    }

    这是jsp页面

    <body>
            <%
            System.out.println("当前session对象的ID号为"+session.getId());
            session.setAttribute("myBean", new MyBean());
            session.removeAttribute("myBean");
            
            
             %>    
  • 相关阅读:
    Ubuntu下 实现Linux与Windows的互相复制与粘贴
    bzoj2426
    bzoj1835
    bzoj1197
    bzoj1049
    bzoj2893
    bzoj1820
    bzoj1819
    bzoj1455
    bzoj3689
  • 原文地址:https://www.cnblogs.com/Baronboy/p/5337897.html
Copyright © 2011-2022 走看看