Redirect与forward

直接上干货Demo:
<%
String [] test=new String[2];
test[0]="1ss";
test[1]="2dd";
request.setAttribute("test",test) ;
//response.sendRedirect("jsp2.jsp"); //不会传递给下一个页面
//request.getRequestDispatcher("jsp2.jsp").forward(request,response);
%>
<jsp:forward page="jsp2.jsp" />

<%
String test[]=(String[])request.getAttribute("test");
out.print(test[0]+" "+test[1]);
out.print(test[1]);
%>

参考文档:
http://zhulin902.iteye.com/blog/939049
http://www.2cto.com/kf/201109/105650.html

你可能感兴趣的:(redirect)