2016-08-05 61 views
-4

在一个项目中所涉及的技术是JEE,primefaces的数量,休眠和JSF(与jsfhelper),我们有以下代码:如何显示活动会话

public static SessionBean getSessionBean() { 

    SessionBean sessionBean = (SessionBean) JsfHelper.getSessionAttribute("SessionBean"); 
    if (sessionBean == null) { 
     sessionBean = new SessionBean(); 
     JsfHelper.setSessionAttribute("SessionBean", sessionBean); 
    } 
    return sessionBean; 
} 

Student student = new Student(); 

public String login() throws Exception { 
    Student studentLogin = studentDao.login(student.getUsername(), student.getPassword()); 
    if (studentLogin.getUsername() != null) { 
     JsfHelper.getSessionBean().setStudent(studentLogin); 
     return "dashboard"; 
    } else { 
     return null; 
    } 
} 

我如何能显示数字或在线用户的名字?

回答

-1

如果你想访问所有连接的用户,你应该使用应用范围。会话范围适用于当前连接的用户。