页面跳转分类有两种:重定向和转发,即redirect和forward。一:重定向redirect第一种方式:controller中返回值为String相关免费学习视频分享:java在线学习public String login(httpse
页面跳转分类有两种:重定向和转发,即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);
--结束END--
本文标题: java后端如何实现页面跳转
本文链接: https://www.lsjlt.com/news/3106.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-03
2024-04-03
2024-04-01
2024-01-21
2024-01-21
2024-01-21
2024-01-21
2023-12-23
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0