Public Class Stu{ private int id; private String name; public void setId(int id){ this.id=id; } public int getId(){ return this.id; } public void setName(String name){ this.name=name; } public String getName(){ return this.name; }}
写个简单的servlet
public class gotoMall extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ArrayList<Stu> stus=new ArrayList<Stu>(); Stu stu1=new Stu(); stu1.setId(1); stu1.setName("aa"); stu2.setId(2); stu2.setName("bb"); stus.add(stu1); stus.add(stu2); request.setAttribute("stus", stus); request.getRequestDispatcher("/WEB-INF/admin/my.jsp").forward(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); }}