Struts2对象栈和值栈的操作

对象栈的操作

把数据存入对象栈栈顶:

<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");






你可能感兴趣的:(struts2,值栈,对象栈,Map栈)