`
typeUSB
  • 浏览: 12181 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
最近访客 更多访客>>
社区版块
存档分类
最新评论

struts 2.0 在action中访问Servlet API

阅读更多
struts 2.0 在action中访问Servlet API
1、通过Actiocontext 访问Servlet API
    ActionContext ctx =ActionContext.getcontext();
    //获得Session
    Map session =ctx.getSession();
    //获得Application
    Map application = ctx.getApplication();
    struts 2.0 获得Request 和 Response这两个对象,Struts 2.0 提供了一个ServletActionContext类:
    //获得 request
    HttpServletRequest  request = ServletActionContext.getRequest();
    //获得httpServletResponse
    HttpServletResponse response = ServletActionContext.getResponse();
    //获得HttpSession
    HttpServletRequest request =ServletActionContext.getRequest();
    HttpSession session = request.getSession();
    //获得 ServletContext
    ServletContext sc = ServletActionContext.getServletContext();
2、通过实现*Aware接口获得Servlet API
    ApplicationWare、CookiesAware、RequestAware、ServletRequestAware、ServletResponseAware、SessionAware
    就可以让Action实现*Aware接口、我们就可以获得其它对象
分享到:
评论

相关推荐

    struts2.0中文教程

    06 在Struts 2.0中实现表单数据校验(Validation) 07 Struts 2的基石——拦截器(Interceptor) 08 在Struts 2中实现IoC 09 在Struts 2中实现文件上传 10 在Struts 2中实现CRUD 11 Struts 2中的OGNL 12 trus 2的新...

    struts2.0struts2.0struts2.0struts2.0struts2.0struts2.0

    struts2.0struts2.0struts2.0struts2.0struts2.0struts2.0struts2.0struts2.0struts2.0struts2.0

    Struts 2.0的Action讲解

    Struts 2.0的Action讲解 com.opensymphony.xwork2.ActionSupport类

    Struts 2.0系列(MAX)

    在Struts 2.0中实现表单数据校验(Validation) Struts 2的基石——拦截器(Interceptor) 在Struts 2中实现IoC 在Struts 2中实现文件上传 在Struts 2中实现CRUD Struts 2中的OGNL Strus 2的新表单标志的使用 ...

    Struts2.0视频教程+struts2.0中文教程

    Struts2.0视频教程,struts2.0中文教程,Struts2.0视频教程,struts2.0中文教程,

    Struts2.0,Hibernate,Spring中文API

    Struts2.0,Hibernate,Spring中文API,三大框架APIStruts2.0,Hibernate,Spring中文API,三大框架APIStruts2.0,Hibernate,Spring中文API,三大框架APIStruts2.0,Hibernate,Spring中文API,三大框架APIStruts2.0,Hibernate,...

    Struts2.0的api

    这是Struts2.0的API文档希望大家一起学习,一起进步。

    sstruts2.0 struts2.0

    sstruts2.0 struts2.0sstruts2.0 struts2.0sstruts2.0 struts2.0sstruts2.0 struts2.0sstruts2.0 struts2.0sstruts2.0 struts2.0sstruts2.0 struts2.0sstruts2.0 struts2.0sstruts2.0 struts2.0

    struts2.0的数据校验框架struts2.0的数据校验框架

    struts2.0的数据校验框架struts2.0的数据校验框架struts2.0的数据校验框架struts2.0的数据校验框架

    struts2.0之action

    有Struts 1.x经验的朋友都知道Action是Struts的核心内容,当然Struts 2.0也不例外。不过,Struts 1.x与Struts 2.0的Action模型很大的区别 本文档对struts2.0 action进行了详细介绍

    JavaEE源代码 Struts2.0

    JavaEE源代码 Struts2.0JavaEE源代码 Struts2.0JavaEE源代码 Struts2.0JavaEE源代码 Struts2.0JavaEE源代码 Struts2.0JavaEE源代码 Struts2.0JavaEE源代码 Struts2.0JavaEE源代码 Struts2.0JavaEE源代码 Struts2.0...

    struts2.0jar包

    struts2.0jar包 struts2.0包 struts2.0源文件

    Struts2.0 Jar包

    此为Struts2.0最新Jar包,方便各位用于Struts2.0的开发.

    Struts 2.0

    清晰的介绍了Struts 2.0框架的工作流程,Action线程安全,程序入口,配置文件。

    struts 2.0 详细配置

    struts 2.0 详细配置 struts 2.0 详细配置 struts 2.0 详细配置

    Struts2.0中文教程权威版

    06 在Struts 2.0中实现表单数据校验(Validation) 07 Struts 2的基石——拦截器(Interceptor) 08 在Struts 2中实现IoC 09 在Struts 2中实现文件上传 10 在Struts 2中实现CRUD 11 Struts 2中的OGNL 12 trus 2的新...

    Struts2.0学习Struts2.0文档

    为Struts 2.0做好准备 Struts作为MVC 2的Web框架,自推出以来不断受到开发者的追捧,得到用广泛的应用。作为最成功的Web框架,Struts自然拥有众多的优点: MVC 2模型的使用 功能齐全的标志库(Tag Library) 开放...

    struts2.0 API

    struts2.0 API 包括了Struts使用的所有类信息,可以向java api一样使用它,初学者可以试着多查查struts api。

    struts2.0入门案例

    struts2.0 入门案例、简单的struts2.0入门案例 2.0配置包,基础

Global site tag (gtag.js) - Google Analytics