import org.apache.shiro.SecurityUtils;
import com.reptile.bean.sys.User;
/**
* @ClassName: WebUtils
* @Description: web公共类
* @author Bert
* @date 2011-10-6 上午10:19:17
*
*/
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().getCnname();
}
return null;
}
}
import com.reptile.bean.sys.User;
/**
* @ClassName: WebUtils
* @Description: web公共类
* @author Bert
* @date 2011-10-6 上午10:19:17
*
*/
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().getCnname();
}
return null;
}
}