WebSphere Portal获取当前登录用户名的三种方式

方法一:采用Portal的Puma API

Context ctx = new InitialContext();
PortletServiceHome pumaServiceHome = (PortletServiceHome) ctx.lookup("portletservice/com.ibm.portal.um.portletservice.PumaHome");				
PumaHome puma_home = null;				
if (pumaServiceHome != null){
		
	puma_home = (PumaHome) pumaServiceHome.getPortletService(PumaHome.class);
}
PumaProfile pp = puma_home.getProfile();
User user = pp.getCurrentUser();
String uid = pp.getIdentifier(user); 
 

方法二:采用传统的Request方式

request.getUserPrincipal().getName();

 

方法三:采用Taglib方式

<%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-fmt" prefix="portal-fmt" %> 
<portal-fmt:user attribute="cn"/>
 

你可能感兴趣的:(IBM,websphere,idea)