当前位置: 代码迷 >> Web前端 >> 在Action里去值栈中存放对象的方法
  详细解决方案

在Action里去值栈中存放对象的方法

热度:100   发布时间:2012-11-23 00:03:43.0
在Action里往值栈中存放对象的方法

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

放到 对象栈中去了

?

  相关解决方案