HttpSession.setAttribute("name","vlaue");

解决方案 »

  1.   

    session.setMaxInactiveInterval(3000);
    session.setAttribute("CDWDHO",log.sDwdh);        
             session.setAttribute("CYGDMO",log.UserName); 
              session.setAttribute("CXMO",log.sXm);    session.setAttribute("power",log.power);
    session.setAttribute("Account",log.sAccounts);
      

  2.   

    在登陆页面设置文本框username读取用户id,在验证页面用String username= request.getParameter("username"); 读取,然后加入到 session.
    session.setAttribute("userid","username");
     在其他页面用session.getAttribute("userid")读出来
      

  3.   

    最简单常用的方法,session.putValue("UserName",User_Name);
      

  4.   

    HttpSession.setAttribute("name","vlaue");
      

  5.   

    不過最好寫一個bean來保存這些Session的信息
      

  6.   

    session.putValue();java已不建议使用
    //设置session值
    session.setAttribute(session.getid(),object);
    //获取
    (OBject)session.getAttribute(session.getid());其中object是自己定义的存放信息的类
      

  7.   

    那如何把Session里的string类型的值读到一个变量呢?
      

  8.   

    String str=session.getAttribute("username");
      

  9.   

    按楼上:String str=session.getAttribute("username");
    给出错信息:: 
    incompatible types
    found   : java.lang.Object
    required: java.lang.String
    String username=session.getAttribute("username");