//得到用戶提交的值 String name = request.getParameter("username"); String pwd = request.getParameter("passWord"); //創建HttpSessio對象 HttpSession s = request.getSession(); //將值綁定在session會話中 s.setAttribute("Sname",name); s.setAttribute("Spwd",pwd); //重定向 response.sendRedirect("yinyu.jsp");
在yinyu.jsp頁面中得到值
//使用session會話取值
String username = (String)session.getAttribute("Sname"); String password = (String)session.getAttribute("Spwd");或者
${Sname}; ${Spwd};
//得到用戶提交的值 String name = request.getParameter("username"); String pwd = request.getParameter("password"); //將值綁定在request中 request.setAttribute("Rname",name); request.setAttribute("Rpwd",pwd); //頁面轉發 RequestDispatcher rd = request.getRequestDispatcher("yinyu.jsp"); rd.forward(request,response);
在yinyu.jsp頁面中得到值
//使用request協助相關取值
String username = (String)request.getAttribute("Rname"); String password = (String)request.getAttribute("Rpwd");或者${Sname};
${Spwd};
setAttribute() | 設置綁定屬性值setAttribute("自定義命名",要綁定的引用); |
getAttribute() | 取出得到屬性值getAttribute("setAttribute中的自定義命名"); |
sendRedirect() | 重定向跳轉頁面sendRedirect("要跳轉的頁面地址"); |
新聞熱點
疑難解答