您的位置:首页 > 编程语言 > Java开发

Struts2对象栈和值栈的操作

2015-09-23 15:16 471 查看
对象栈的操作

把数据存入对象栈栈顶:

<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");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: