我没有看到你把用户信息对象放进session里,你可以调试一下你的程序执行流程

解决方案 »

  1.   

    补充一下,AccessControl类里面刚刚漏了一个方法/**
     * 保存session对象
     */
    public void setSession(Map session) {
       this.session = session;
    }
      

  2.   

    在ActionSupport子类的execute方法中存储session
    Map session = ActionContext.getContext().getSession();
    session.put("logged-in","true"); 同样在execute方法中,可以清除session变量
    Map session = ActionContext.getContext().getSession();
    session.remove("logged-in"); 在jsp的head部分引入css文件
    <head>
         <link href="<s:url value="/css/main.css"/>" rel="stylesheet" type="text/css"/>  
    </head>在jsp访问session
    session Time: </b><%=new Date(session.getLastAccessedTime())%> <a href="<%= request.getContextPath() %>/roseindia/logout.action">Logout</a> jsp中使用struts-tag访问session变量
    <s:if test="#session.login != 'admin'">
     <jsp:forward page="/pages/uiTags/Login.jsp" />  
    </s:if>
      

  3.   

    1 其他地方是不是也用的是getInstance来获取AccessControl2 LoginAction实现SessionAware 方法后,是否在setSession方法中this.session = session
      

  4.   

    在LoginAction中实现了SessionAware后已经实现了setSession方法。
      

  5.   

    可能是由于AccessControl 类的初始化问题导致的,AccessControl 不是一个action也许得不到上下文,猜测吧你可以在页面上,或者其他的真正的action里面,直接用
    StaffInfoBean loginStaff = (StaffInfoBean) ServletActionContext.getRequest().getSession().getAttribute("user_bean");
    来获得一下,看看有没有值
      

  6.   

    没看出问题  debug一下看看
      

  7.   


    (StaffInfoBean) ServletActionContext.getRequest().getSession().getAttribute("user_bean");
    改为
    (StaffInfoBean)session.get("user_bean");