public class Login extends ActionSupport {
private Map request;
private Map session;
private Map application;
public Login() {
request = (Map) ActionContext.getContext().get("request");
session = ActionContext.getContext().getSession();
application = ActionContext.getContext().getApplication();
}
@Override
public String execute() throws Exception {
request.put("rrr", "rrr");
session.put("sss", "sss");
application.put("aaa", "aaa");
return SUCCESS;
}}
通过ActionContext.getContext()方法得到上下文对象
用getXXX方法得到相关Map
我想知道
在自己定义的类里定义的成员变量request 虽然从上下文中得到了对应的request信息
但是明明是往自己定义的request里put 为什么会put到Stack Context的request里?

解决方案 »

  1.   

    “自己定义的request”?你自己定义的request还不是从Context中取得到的
      

  2.   

    这是你的 request ,看看从哪里来的request = (Map) ActionContext.getContext().get("request");
      

  3.   

    请百度java 对象引用.
    基础不讲好就讲SSH的老师害死人啊.
      

  4.   

    咋不用ServletActionContext类呢,可以直接得到request和response啊
    ServletActionContext.getRequest();
    ServletActionContext.getResponse();
      

  5.   

    诸如此类的获得方式都是属于系统的预设对象
    application, session, requestMap application = (Map) ActionContext.getContext().get("application");
    application.put("myId",myProp);
    Map session = (Map) ActionContext.getContext().get("session");
    session.put("myId", myProp);
    Map request = (Map) ActionContext.getContext().get("request");
    request.put("myId",myProp);
      

  6.   

    没有实现RequestAware接口,值栈应该得不到request put进去的值吧 ?