public class UserContext {
public static final String USER_IN_SESSION = "user";
public static void setUser(Employee employee){
// 获取当前登录用户
Subject subject = SecurityUtils.getSubject();
// 把用户信息放到session
subject.getSession().setAttribute(USER_IN_SESSION, employee);
}
/**
* @return 返回session中的用户信息
*/
public static Employee getUser(){
return (Employee)SecurityUtils.getSubject().getSession().getAttribute(USER_IN_SESSION);
}
}