foreach 案例

来源:互联网 发布:酷派线刷软件哪个好 编辑:程序博客网 时间:2024/05/21 17:40


public String test33(){
  System.out.println("进来了");
  Test4 t = new Test4();
    t.setAge(10);
    t.setName("人");
   Test4 t2 = new Test4();
    t2.setAge(20);
    t2.setName("人人");
   
 List ts = new ArrayList();
    ts.add(t);
    ts.add(t2);
  ActionContext actx = ActionContext.getContext();
  HttpServletRequest hrequest = (HttpServletRequest) actx.get(ServletActionContext.HTTP_REQUEST);
  hrequest.getSession().setAttribute("ts",ts);
  hrequest.getSession().setAttribute("t",t);
  hrequest.getSession().setAttribute("t2",t2);
  return "test33";
   
 }

  <c:forEach  items="${ts}" var="t">
     ${t.age}-----${t.name}<br/>     
  </c:forEach>

0 0
原创粉丝点击