@SuppressWarnings("deprecation")
public String getCurrentUserId(PortletRequest request) {
UserPrincipal user = null;
PortalSession ps = (PortalSession) request.getPortletSession().getAttribute(PortalSession.PORTAL_SESSION_KEY);
if (ps != null) {
user = (UserPrincipal) ps.getCurrentUser();
}
String userId = null;
if (user != null) {
userId = user.getName();
System.out.println(this.getClass().toString()+" " + userId);
if (userId != null) {
userId = userId.toLowerCase();
}
}
return userId;
}
获取当前登录用户的信息的代码
最新推荐文章于 2024-03-07 10:20:41 发布