注:由index.jxp跳转到Failure.jsp
request.getSession().setAttribute("msg", "45654");
方法一:
response.sendRedirect("Failure.jsp");
特点:
(1)不能传值
(2)地址跳转
方法二:
Index.jsp
request.getSession().setAttribute("msg", "45654");
request.getRequestDispatcher("Failure.jsp").forward(request, response);
Failure.jsp
Object o =request.getSession().getAttribute("msg");
out.print(o);
特点:
(1)可以传值
(2)地址不跳转

本文介绍了两种在JSP中实现页面跳转的方法:sendRedirect和dispatcher.forward,并对比了它们的特点,包括是否能传递值及地址栏的变化。
7770

被折叠的 条评论
为什么被折叠?



