07hnust

导航

退出系统须采取的方法

退出系统的jsp:

<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />

<title>allsuccess.jsp</title>

</head>

<body>

 <form action="leave.do">
  <input type="submit" value="退出系统" name="submit">
 </form>
 <br>
 <br> Operation Success !
</body>
</html:html>

LeaveAction:

public class LeaveAction extends Action
{
   public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response)
 {
  request.getSession().invalidate();//清除Session中的所有对象,注销必须采用
  System.out.println(request.getSession().getValue("user"));//测试对象是否被清除。应该返回值null
  System.out.println(request.getSession().getValue("fcompanyId"));//测试对象是否被清楚,返回null
  System.out.println("----------------------------------------");
  return mapping.findForward("leave");
 }
}

 

posted on 2012-03-09 15:13  07hnust  阅读(228)  评论(0编辑  收藏  举报