jsf 是java server face 的意思吧,没有用过,知道是sun公司的产品!加油呀,好好学,今后还会向你请都教呀;

解决方案 »

  1.   

    老兄呀,同病相连呀,都是初学jsf ,难呀
      

  2.   

    登入时用FacesUtils.getSessionScope().put("user", user)
    之后用 FacesUtils.getSessionScope().get("user")判断
      

  3.   

    OH, my god! Thank you, I will try later..
      

  4.   

    FacesUtils 找不到这个类啊..啊.....??
      

  5.   

    FacesUtils是自定义的工具类;登录成功后设置用户session
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("userId",userId);
    在后台可以通过
    if(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("userId") != null)
    来判断是否登录;在页面则可通过
    facesContext.externalContext.sessionMap['userId'] != null
    来判断是否登录;exp(页面判断):
    <h:commandLink value="Login" action="#{loginBean.loginAction}" rendered="#{facesContext.externalContext.sessionMap['userId'] == null}"/>
    <h:commandLink value="userName:[Logout]" action="#{loginBean.loginAction}" rendered="#{facesContext.externalContext.sessionMap['userId'] != null}"/>或者可以直接用jsp提供的方法来判断也行:
    <%if(session.getAttribute("userId") != null){%>
       <h:commandLink value="userName:[Logout]" action="#{loginBean.loginAction}"/>
    <%}else{%>
       <h:commandLink value="Login" action="#{loginBean.loginAction}"/>
    <%}%>