ActionContext.getContext().put("departmentList",departmentList);
是直接往 map栈中存放元素
Stack Context
Key Value
departmentList [cn.xiaoxian.domain.Department@8098]
<s:iterator value="departmentList"> 注意没用#
--------------------------------
ServletActionContext.getRequest().setAttribute("departmentList",departmentList);
放到request域中
所以要这样访问 <s:iterator value="#request.departmentList">
---------------------------------
ActionContext.getContext().getValueStack.push(departmentList);
<s:iterator> 因为没有对象名 可对象在栈顶 所以直接用<s:iterator>迭代栈顶的元素
---------------------------------
ActionContext.getContext().getValueStack.set("departmentList",departmentList);
做了一个HashMap "departmentList"做为key ,departmentList作为value
放到 对象栈中去了
Struts2中不同作用域使用详解
本文详细解析了在Struts2框架中如何使用不同的作用域来存储和访问数据,包括ActionContext、StackContext及请求作用域的使用方法,并通过具体的代码示例展示了这些作用域的区别。

被折叠的 条评论
为什么被折叠?



