//首先需要导入包
//action 内处理 session 需要导入的类
import com.opensymphony.xwork2.ActionContext;
session
//方法一:
public class SessionContext {
public static final String GLOBLE_USER_SESSION = "globle_user";
public static void setUser(Employee user){
if(user!=null){
ServletActionContext.getRequest().getSession().setAttribute(GLOBLE_USER_SESSION, user);
}else{
ServletActionContext.getRequest().getSession().removeAttribute(GLOBLE_USER_SESSION);
}
}
public static Employee get(){
return (Employee) ServletActionContext.getRequest().getSession().getAttribute(GLOBLE_USER_SESSION);
}
}
//方法二:
// 创建 ActionContext
ActionContext actionContext = ActionContext.getContext();
Map