我已经写了下面的代码,但它始终返回用户ID(数字,例如'40156','20147'e.t.c),而不是用户名
有人可以告诉我如何获取屏幕名称
ThemeDisplay themeDisplay;
HttpServletRequest httpRequest;
themeDisplay = (ThemeDisplay) httpRequest.getAttribute(WebKeys.THEME_DISPLAY);
User user = null;
long userId1 = themeDisplay.getUserId();
user = UserLocalServiceUtil.getUserById(userId1);
String screenname1 = user.getScreenName();
最佳答案
我在Java类中使用了以下代码,现在我可以使用以下代码获取屏幕名称
现在,“用户”对象的屏幕名称在变量_originalScreenName中
HttpServletRequest request;
long companyID = PortalUtil.getCompanyId(request);
User user = UserLocalServiceUtil.getUserByEmailAddress(companyID, EmailID);