Struts2对象栈和值栈的操作

来源:互联网 发布:恒大淘宝股票834338 编辑:程序博客网 时间:2024/06/05 00:35

对象栈的操作

把数据存入对象栈栈顶:

<span style="white-space:pre"></span>ActionContext.getContext().getValueStack().push("aaa");ActionContext.getContext().getValueStack().getRoot().add(0,"bbb");ActionContext.getContext().getValueStack().set("ccc", "ccc");//把一个Map放到对象栈的栈顶
把数据从对象栈栈顶取出:

<span style="white-space:pre"></span>ActionContext.getContext().getValueStack().peek();ActionContext.getContext().getValueStack().getRoot().get(0);
把数据从对象栈栈顶移除:

<span style="white-space:pre"></span>ActionContext.getContext().getValueStack().pop();ActionContext.getContext().getValueStack().getRoot().remove(0);
Map栈的操作

把数据放到Request域:

ServletActionContext.getRequest().setAttribute("aaa", "aaa");

把数据放到session域:

ServletActionContext.getRequest().getSession().setAttribute("aaa", "aaa");

把数据放到Application域:

ServletActionContext.getServletContext().setAttribute("aaa", "aaa");
把数据直接放到Map栈:

ActionContext.getContext().put("aaa", "aaa");






0 0
原创粉丝点击