首页 > 其他 > 详细

监听器

时间:2017-08-04 21:11:32      阅读:196      评论:0      收藏:0      [点我收藏+]
/*
 * 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); } } }

 

监听器

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!