版权声明
1. 本站文章和资源均来自互联网收集和整理,本站不承担任何责任及版权问题。
2. 相关版权归作者及其公司所有,仅供学习研究用途,请勿用于商业目的。
3. 若侵犯您的版权,请发邮件至webmaster@ishare1.cn联系我们,我们确认后将立即删除。

页面跳转分类有两种:重定向和转发,即redirect和forward。
一:重定向redirect
第一种方式:controller中返回值为String
相关免费学习视频分享:java在线学习
public String login(HttpServletRequest req, HttpServletResponse resp) return "redirect:http://localhost:8080/index";
第二种方式:controller中返回值为void
public void login(HttpServletRequest req, HttpServletResponse resp)
resp.sendRedirect("http://localhost:8080/index");
第三种方式:controller中返回值为ModelAndView
return new ModelAndView("redirect:/toList");
二:转发forward
例如:
request.getRequestDispatcher("/student_list.jsp").forward(request, response);
相关文章教程推荐:java入门教程
爱分享




