首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts2的拦截器的getInvocationContext()跟使用ActionContext.getContext()有什么不同

2012-09-13 
struts2的拦截器的getInvocationContext()和使用ActionContext.getContext()有什么不同?struts2的拦截器的

struts2的拦截器的getInvocationContext()和使用ActionContext.getContext()有什么不同?
struts2的拦截器的intercept方法中使用invocation.getInvocationContext()和使用ActionContext.getContext()有什么不同?


ActionContext.getContext().getsession().put("test","123");


  public String intercept(ActionInvocation invocation)    {ActionContext ac = invocation.getInvocationContext();  String s=(String)ac.getsession.get("test");

  }
s为null的

相反使用
 public String intercept(ActionInvocation invocation)  {     ActionContext ac = invocation.getInvocationContext();    ac.getSession().put("test","123");  }


  在
 
  ActionContext actionContext = ActionContext.getContext();    Map session= actionContext.getSession();   String s2=(String)session.get("test");

这里的s2就有值了,在拦截器也有值。

有什么不同的?

热点排行