在项目里面用的struts2,在action里面能正确取到session
但如果不是在action里面,没有用action,我直接弹出一个页面,在页面里面就取不到session,这是怎么回事呀.
取session我是这样取的
Map mapSession = ServletActionContext.getContext().getSession();在action里面能取到,如果页面是通过action跳转过去的也能正确取到,但如果页面是直接window.open()出来的就取不到,为什么呀????

解决方案 »

  1.   

    我也不知道呀.我弹出的页面用
    Map mapSession = ServletActionContext.getContext().getSession(); 
    取得mapSession为null ,如果页面是通过action跳转过去的就能取到.郁闷死了.
      

  2.   

    只是在jsp页面里取session吗
    直接用el试下
      

  3.   

    ...jsp里不是直接session.getAttribute()就好了
      

  4.   

    恩?还真是奇怪呀,应该可以取到吧,是不是你把cookie给禁用了呀~~
      

  5.   

    楼主你注入一个hidden的属性,试试应该就可以了
      

  6.   

    用session.getAttribute()能够取到,
    但用struts2提供的ServletActionContext.getContext().getSession(); 怎么就了不到呢,郁闷哟.
      

  7.   

    应该这样取session
    ActionContext.getContext().getSession();
      

  8.   

    ServletActionContext是struts2对session的一个映射,既然没走action那么就没办法在ServletActionContext对session做映射,如此而已。
      

  9.   

    ServletActionContext.getContext().getSession();是struts2对session的一个映射
      

  10.   


    到了jsp页面上,可以直接用session它是隐含对象,页面已经 不是struts2的范围了