/**
* @ClassName: SessionUtils.java
* @Description: 会话帮助类
* @author Bert
* 2014-4-1 下午4:54:51
*/
public class SessionUtils {
/**
* 获取登录用户
*/
public static User getUser() {
return (User) SecurityUtils.getSubject().getSession().getAttribute(ResourceUtils.getSessionInfoName());
}
/**
* 获得用户ID
*
* @return
*/
public static String getUserID() {
if (getUser() != null) {
return getUser().getId();
}
return null;
}
/**
* 获得用户名
*
* @return
*/
public static String getUserName() {
if (getUser() != null) {
return getUser().getUsername();
}
return null;
}
}
* @ClassName: SessionUtils.java
* @Description: 会话帮助类
* @author Bert
* 2014-4-1 下午4:54:51
*/
public class SessionUtils {
/**
* 获取登录用户
*/
public static User getUser() {
return (User) SecurityUtils.getSubject().getSession().getAttribute(ResourceUtils.getSessionInfoName());
}
/**
* 获得用户ID
*
* @return
*/
public static String getUserID() {
if (getUser() != null) {
return getUser().getId();
}
return null;
}
/**
* 获得用户名
*
* @return
*/
public static String getUserName() {
if (getUser() != null) {
return getUser().getUsername();
}
return null;
}
}