码迷,mamicode.com
首页 > 其他好文 > 详细

监听器

时间:2017-08-04 21:29:51      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:package   admin   new   attr   nis   public   port   null   err   

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.toher.listener;

import cn.toher.bean.User;
import cn.toher.dao.UserLogDao;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 *
 * @author Administrator
 */
public class SessionListener implements HttpSessionListener {

    public SessionListener() {
    }

    ;

    @Override
    public void sessionCreated(HttpSessionEvent se) {
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        HttpSession session = se.getSession();
        User user = (User) session.getAttribute("Suser");
// 监听session中的user,如果它为空,则去动作
if (user != null) { UserLogDao userLogDao = new UserLogDao(); userLogDao.addTimeout(user); } } }

 

监听器

标签:package   admin   new   attr   nis   public   port   null   err   

原文地址:http://www.cnblogs.com/itchenfirst/p/7287035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!