logoffaction.java

来自「JSP2.0实用教程实例源码」· Java 代码 · 共 44 行

JAVA
44
字号
package app;

import java.io.IOException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.util.MessageResources;

public final class LogoffAction extends Action {

    /**
     * Logoff the user.
     * The event is logged if the debug level is >= Constants.DEBUG.
     *
     * @param mapping The ActionMapping used to select this instance
     * @param actionForm The ActionForm bean for this request (if any)
     * @param request The HTTP request we are processing
     * @param response The HTTP response we are creating
     *
     * @exception IOException if an input/output error occurs
     * @exception ServletException if a servlet exception occurs
     */
    public ActionForward perform(ActionMapping mapping,
         ActionForm form,
         HttpServletRequest request,
         HttpServletResponse response)
            throws IOException, ServletException {

      // Extract attributes we will need
      HttpSession session = request.getSession();
      LogonForm user = (LogonForm)
        session.getAttribute(Constants.USER_KEY);

      // Remove user login
      session.removeAttribute(Constants.USER_KEY);

      // Return success
      return (mapping.findForward(Constants.SUCCESS));

    }

} // end LogoffAction

⌨️ 快捷键说明

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