日期:2014-05-17 浏览次数:20738 次
package com.test.action; import java.util.Map; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; import com.test.service.Iservice; public class ListUserAction extends ActionSupport { private Iservice service; public Iservice getService() { return service; } public void setService(Iservice service) { this.service = service; } @SuppressWarnings("unchecked") @Override public String execute() throws Exception { Map request = (Map) ActionContext.getContext().get("request"); request.put("list",service.listUser()); return SUCCESS; } }
<s:iterator value="#request.list" id="us"> <tr> <td><s:property value="#us.id"/> </td> <td><s:property value="#us.firstname"/> </td> <td><s:property value="#us.lastname"/> </td> <td><s:property value="#us.age"/> </td> </tr> </s:iterator>
public List<User> listUser() { String hql = "from User user order by user.id desc"; return (List<User>)this.getHibernateTemplate().find(hql); }