看代码:
         Person person = r.getUser();

OrgPerson op = new OrgPerson();
op.setRecid(person.getId());
op.setEduLevel(person.getEduLevel());
op.setEmail(person.getEmail());
op.setJob(person.getJob());
request.getSession().setAttribute("person",person);
我把用户信息放到session里,我用的是ssh,现在我想在action里面获取出来用户的ID信息,应该怎么写,详细点,本人菜鸟,谢谢哈~~

解决方案 »

  1.   

    Session().getAttribute("person");强转成Person对象.
      

  2.   

    那我应该怎么获取ID啊,我是写的 Object obj=request.getSession().getAttribute("person");
    再然后我想获取ID就不会了
      

  3.   

    Person p=(Person )request.getSession().getAttribute("person");
      

  4.   

    是struts几? 1 还是2 ?如果是struts2、
    在action里
    import com.opensymphony.xwork2.ActionContext;
    ActionContext actionContext =  ActionContext.getContext();  
    Map session = ctx.getSession(); //session 
    Person person = (Person )session.get("person");
      

  5.   

    笔误:
    修正import com.opensymphony.xwork2.ActionContext;public String execute() throws Exception {
      ActionContext actionContext =  ActionContext.getContext();  
      Map session = actionContext.getSession(); //session 
      Person person = (Person )session.get("person");
      return SUCCESS;
    }