1
我有如下定義一個CDI豆:如何刪除CDI會話範圍的bean
@Named("loginBean")
@SessionScoped
public class LoginBean implements Serializable {
@EJB
private LoginManager loginManager;
private String username;
private String password;
現在我想從程序會話範圍中刪除:
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
LoginBean ins = (LoginBean)session.getAttribute("loginBean");
但ins
變量始終爲空。如何檢索loginBean
實例並銷燬它?
[How to invalidate session in JSF 2.0?](http://stackoverflow.com/questions/5619827/how-to-invalidate-session-in-jsf-2-0) – mabi
此外,規範鏈接關於範圍:http://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope – mabi