Java后端实现页面跳转
页面跳转分类有两种:重定向和转发,即redirect和forward。
具体区别和含义最后介绍,先给出使用方法。
一:重定向redirect
第一种方式:controller中返回值为String
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("/index").forward(request, response);
最后
以上就是忧心电话最近收集整理的关于# Java后端实现页面跳转Java后端实现页面跳转的全部内容,更多相关#内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复