官方解释:

  The ActionContext is the context in which an {@link Action} is executed. Each context is basically a container of objects an action needs for execution like the session, parameters, locale, etc.  The ActionContext is thread local which means that values stored in the ActionContext are  unique per thread. See the {@link ThreadLocal} class for more information. The benefit of this is you don't need to worry about a user specific action context, you just get it:  

  <code>ActionContext context = ActionContext.getContext();</code>

Finally, because of the thread local usage you don't need to worry about making your actions thread safe.

  ActionContext是一个Action执行的上下文(现场).每一个Context是一个action执行所需要的数据的容器,这个容器中保存着session,parameters,locale等等.The ActionContext is thread local which means that values stored in the ActionContext are  unique per thread. 这样设计的好处就是让开发者不用担心action的使用,只需要大胆使用就可以了,无需来保证它的线程安全.

   原来我们所取得的ctx来自于 ThreadLocal 啊!熟悉ThreadLocal 的朋友都知道它是与当前线程绑定的 

Struts2自定义的一个数据的容器.ActionContext是个map集合,它持有了web标准的4个域(pagecontext域,request域,session域,application域(servlet开发 context)),通过它可以直接获取这四个标准容器。

不仅如此,它还引用了其它struts 2自己定义的对象:

ActionContext的几个特点:

1,ActionContext是strtuts2新设计出来的存储数据的容器,该容器是个map集合

它里面持有到达各个容器(其它map)的引用,如可以获取标准的4个域容器,还有struts 2自己定义的东西,如valuestack值栈

2,我们可以通过 ActionContext方便的获取到其它容器,如同一个快捷方式,struts 2的数据中心

3,ActionContext是threadloacl线程绑定的, 当struts 2接受到请求后,就会马上创建一个ActionContext,然后各个位置都可以获取到ActionContext

4,ActionContext意思就是action运行的上下文,负责存储action运行需要/产生的数据

5,ActionContext它里面有个map集合用来存储数据,但是ActionContext本身作为一个对象,它也有很多其它开发方法 。

ActionContext.getcontext()  :获取ActionContext里的大map集合;ActionContext.getcontext().getvaluestack()  //获取值栈

[参考]

  http://www.makaidong.com/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E7%89%9B/32881.shtml

Struts2-ActionContext的更多相关文章

  1. struts2中 ServletActionContext与ActionContext区别

    1. ActionContext 在Struts2开发中,除了将请求参数自动设置到Action的字段中,我们往往也需要在Action里直接获取请求(Request)或会话(Session)的一些信息, ...

  2. Struts2中ActionContext及ServletActionContext介绍(转载)

    1. ActionContext 在Struts2开发中,除了将请求参数自动设置到Action的字段中,我们往往也需要在Action里直接获取请求(Request)或会话(Session)的一些信息, ...

  3. ActionContext和ServletActionContext区别

    1. ActionContext 在Struts2开发中,除了将请求参数自动设置到Action的字段中,我们往往也需要在Action里直接获取请求(Request)或会话(Session)的一些信息, ...

  4. Struts2中获取HttpServletRequest,HttpSession等的几种方式

    转自:http://www.kaifajie.cn/struts/8944.html package com.log; import java.io.IOException; import java. ...

  5. ActionContext和ServletActionContext小结(转)

    ActionContext和ServletActionContext小结 1. ActionContext 在Struts2开发中,除了将请求参数自动设置到Action的字段中,我们往往也需要在Act ...

  6. ActionContext和ServletActionContext小结

    1. ActionContext 在Struts2开发中,除了将请求参数自动设置到Action的字段中,我们往往也需要在Action里直接获取请求(Request)或会话(Session)的一些信息, ...

  7. struts2中action手动获取參数

    struts2中action手动获取Session,jsp页面參数 1. ActionContext 在Struts2开发中,除了将请求參数自己主动设置到Action的字段中,我们往往也须要在Acti ...

  8. ActionContext 与 ServletActionContext获取Session的异同

    1. ActionContext 在Struts2开发中,除了将请求参数自动设置到Action的字段中,我们往往也需要在Action里直接获取请求(Request)或会话(Session)的一些信息, ...

  9. 获得HttpServletResponse及其他对象

    下面只列出获得 HttpServletResponse 对象的方法,获得 HttpServletRequest 对象方法类似. 在struts1.x Action类的execute方法中,有四个参数, ...

  10. 在Action类中获得HttpServletResponse对象的四种方法

    在struts1.xAction类的execute方法中,有四个参数,其中两个就是response和request.而在Struts2中,并没有任何参数,因此,就不能简单地从execute方法获得Ht ...

随机推荐

  1. datatable,查询,排序,复制等操作

    DataTable排序,检索,合并详解 一.排序 获取DataTable的默认视图 对视图设置排序表达式 用排序后的视图导出的新DataTable替换就DataTable (Asc升序可省略,多列排序 ...

  2. monkeyrunner学习--手机按键

    按下HOME键 device.press('KEYCODE_HOME','DOWN_AND_UP') 按下BACK键 device.press('KEYCODE_BACK','DOWN_AND_UP' ...

  3. word-break与word-wrap

    本文列举了兼容 IE 和 FF 的换行 CSS 推荐样式,详细介绍了word-wrap同word-break的区别.  兼容 IE 和 FF 的换行 CSS 推荐样式 最好的方式是 以下是引用片段: ...

  4. Linux安装make无法使用

    1.apt-get update 2.apt-get install g++ 3.apt-get install pentium-builder 4.apt-get install build-ess ...

  5. c++ cout 保留小数点位

    需要头文件 <iomanip> 输出时需要用 fixed 和 setprecision() fixed代表输出浮点数,setprecision()设置精度. #include <io ...

  6. 46. Lotus Notes中编程发送邮件(一)

    邮件是Lotus Notes体系的核心和基本功能,以至于Send()是NotesDocument的一个方法,任何一个文档都可以被发送出去,Notes里的一封邮件也只是一个有一些特殊字段的文档.在程序开 ...

  7. 变脸不变质的桥梁模式(Bridge Pattern)

    有一哥们是搞山寨货的,什么流行就搞什么.自己有个厂子,前些时间服装挣钱,就生产衣服,如今搞手机挣钱,搞手机,这哥们非常聪明,就换了个产品,工人,厂房都不变.他是怎么做到的?用类图来模拟一下: 由类图能 ...

  8. kendo ui grid 汉化

    加入js引用 <link href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.common.min.css" r ...

  9. 谁动了我的CurrentPrincipal?解释一下为什么CurrentPrincipal变了,并解决这个问题。

    在上一篇博客中我遇到了一个问题,并且导致了我无法继续进行授权和验证.经过查阅资料和解决另外一个问题的过程,我突然想通了为什么CurrentPrincipal变了.并且经过验证后的确是我所理解的那样.下 ...

  10. C# Webservice

    c#webservice的简单示例   webservice传递的数据只能是序列化的数据,典型的就是xml数据. 下面以一个简单例子为例: (一)新建——-项目---Visual C#---web-- ...