Liferay,在 Filter 中如何获取登录用户信息?

张超 发布于 2012/12/13 15:06
阅读 1K+
收藏 0

新建了一个 Liferay Project ,然后写了一个 Filter ,在 Filter 中如何获取登录用户信息?

以下方法均失败:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		//1.
		String userId = ((HttpServletRequest)request).getRemoteUser();

		//2.
		HttpSession ses = ((HttpServletRequest)request).getSession();
		String userId = (String) ses.getAttribute("USER_ID");

		//3.
		ThemeDisplay themeDisplay = (ThemeDisplay)  ((HttpServletRequest)request).getAttribute(WebKeys.THEME_DISPLAY);
		User user = themeDisplay.getUser();

		//4.
		User user = PortalUtil.getUser((HttpServletRequest)request);

		chain.doFilter(request, response);
	}

加载中
0
丶Format
丶Format

楼主解决了吗?

张超
张超
没有
返回顶部
顶部