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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章