可能重複:
How to pass an Object from the servlet to the calling JSP如何將對象從servlet傳遞到JSP?
如何傳遞對象由servlet來JSP?
我已經使用在servlet側
request.setAttribute("ID", "MyID");
request.setAttribute("Name", "MyName");
RequestDispatcher dispatcher = request.getRequestDispatcher("MangeNotifications.jsp");
if (dispatcher != null){
dispatcher.forward(request, response);
}
以下代碼,該代碼在JSP側
<td><%out.println(request.getAttribute("ID"));%> </td>
<td><%out.println(request.getAttribute("Name"));%> </td>
我得到的JSP頁面
你嘗試了什麼?你在哪裏失敗?你期待什麼?你得到了什麼? – npinti
dup:http://stackoverflow.com/questions/12033092/how-to-pass-an-object-from-the-servlet-to-the-calling-jsp –
http://stackoverflow.com/questions/12033092/how-to-pass-an-object-from-the-servlet-to-the-calling-jsp/12033175#12033175 –