Action中访问Servlet API

来源:互联网 发布:和飞行员谈恋爱 知乎 编辑:程序博客网 时间:2024/06/05 04:35

Struts2提供两种访问方式:

伪访问:借助ActionContext

---ActionContext没有构造方法,要使用staticgetContext()方法来获取

     ActionContext提供getSession()getApplication()两个方法

      来模拟访问HttpSessionServletContext.

           两者返回值均为Map<String,Object> .

真访问(比如添加Cookie):借助ServletActionContext

               --ServletActionContext提供如下静态方法:

    static  PageContext  getPageContext()

    static  HttpServletRequest  getRequest()

    static  HttpServletResponse  getResponse()

    static  ServletContext  getServletContext()

 

0 0