Struts2 ActionContext

一、定义

ActionContext是Action的上下文,Struts2自动在其中保存了一些在Action执行过程中所需的对象,比如session, parameters, locale等。Struts2会根据每个执行HTTP请求的线程来创建对应的ActionContext,即一个线程有一个唯一的ActionContext。因此,使用者可以使用静态方法ActionContext.getContext()来获取当前线程的ActionContext。

二、方法简介

(1)static ActionContext getContext()
          Returns the ActionContext specific to the current thread.

(2)Map<String,Object>   getParameters()
          Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of parameters otherwise.

(3)Map<String,Object>  getSession()
          Gets the Map of HttpSession values when in a servlet environment or a generic session map otherwise.

(4)Map<String,Object>  getApplication()
          Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise.

(4)ValueStack     getValueStack()
          Gets the OGNL value stack.

(5)void    put(String key, Object value) 
          Stores a value in the current ActionContext.

(6)Object  get(java.lang.String key)
          Returns a value that is stored in the current ActionContext by doing a lookup using the value's key.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值