Servlet跳转jsp并将list传给jsp

Servlet将list传给jsp,类似jsp中的pageContext.setAttribute("emplist", lists);并将list传给jsp

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("servlet配置成功");
 		List lists = new ArrayList();
 		lists = UserDao.search();
 		request.setAttribute("emplist", lists);//将lists放到作用域
 		request.getRequestDispatcher("search.jsp").forward(request,response);//跳转到search.jsp
 		
	}


 
  

你可能感兴趣的:(Java)