logout.java

来自「一个jsp写的bbs」· Java 代码 · 共 62 行

JAVA
62
字号
package com.laoer.bbscs.web.action;

import javax.servlet.http.*;

import org.apache.struts.action.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.comm.*;
import com.laoer.bbscs.exception.*;
import com.laoer.bbscs.service.*;
import com.laoer.bbscs.service.config.*;
import com.laoer.bbscs.web.servlet.*;

public class Logout
    extends BaseAction {

  private SysConfig sysConfig;

  private UserOnlineService userOnlineService;

  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                               HttpServletResponse response) {
    UserSession us = this.getUserSession(request);
    if (us != null) {
      UserOnline uo = this.getUserOnlineService().findUserOnlineByUserID(us.getId());
      if (uo != null) {
        try {
          this.getUserOnlineService().removeUserOnline(uo);
        }
        catch (BbscsException ex) {
        }
      }
      //this.getUserPermissionCache().remove(us.getId());
    }
    HttpSession session = request.getSession();
    session.removeAttribute(Constant.USER_SESSION_KEY);
    UserCookie uc = this.getUserCookie(request, response, this.getSysConfig());
    uc.removeAllCookies();
    if (this.getSysConfig().getLogoutUrl().startsWith("/")) {
      return new ActionForward(BBSCSUtil.getActionMappingURL(this.getSysConfig().getLogoutUrl()), true);
    }
    else {
      return new ActionForward(this.getSysConfig().getLogoutUrl(), true);
    }
  }

  public SysConfig getSysConfig() {
    return sysConfig;
  }

  public UserOnlineService getUserOnlineService() {
    return userOnlineService;
  }

  public void setSysConfig(SysConfig sysConfig) {
    this.sysConfig = sysConfig;
  }

  public void setUserOnlineService(UserOnlineService userOnlineService) {
    this.userOnlineService = userOnlineService;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?