最常用的
public class ListAction extends ActionSupport implements RequestAware{ private Map<String,Object> request; StuffDao sd=new StuffDaoImp(); @Override public String execute() throws Exception { List<Stuff> stuffs=sd.list(); request.put("list", stuffs); return SUCCESS; } public void setRequest(Map<String, Object> request) { this.request=request; } }
实现RequestAware
用标签显示list
首先
<%@taglib prefix="s" uri="/struts-tags" %>
<s:iterator value="#request.list" id='stuff'> <tr> <td><s:property value='#stuff.id'/></td> <td><s:property value='#stuff.name'/></td> </tr> </s:iterator>