SSH 中用iterator取得业务层list疑问
action
public class PageAction extends GeneralAction {
/**
*
*/
private static final long serialVersionUID = 1L;
public static final String PAGE_ID = "a";
private ArrayList<Submenu> list;
public ArrayList<Submenu> getList() {
return list;
}
public void setList(ArrayList<Submenu> list) {
this.list = list;
}
private PageService pageService;
public void setPageService(PageService pageService) {
this.pageService = pageService;
}
@Override
Boolean executeService() throws Exception {
HashMap<String, String> param = new HashMap<String, String>();
// 如果成功,传递表单数据传到hashmap
param.put(Parameters.PAGE_ID, PAGE_ID);
list = pageService.sub(param);
HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("l", list);
return true;
}
jsp
<s:iterator value="#request.l">
</s:iterator>
这样还是取不到list 我debug时候list = pageService.sub(param); 中的list能取到值 但是传不到jsp页面 怎么能让jsp显示list?
求大神指点
ssh
iterator
------解决方案--------------------
struts框架已经包装了页面参数和action中变量的相互传递,既然你已经定义了list变量,只需要提供setter/getter方法,然后赋值就可以了,前台你用的s标签,是可以获取值了。其实你已经定义了变量,同时提供了设置和获取方法
这样写试试:
<s:iterator var="submenu" value="list">