There are two types of page jump categories: redirection and forwarding, namely redirect
and forward
.
1: Redirect redirect
The first way: the return value in the controller is String
Related free learning video sharing:java Online learning
public String login(HttpServletRequest req, HttpServletResponse resp) return "redirect:http://localhost:8080/index";
The second way: the return value in the controller is void
public void login(HttpServletRequest req, HttpServletResponse resp) resp.sendRedirect("http://localhost:8080/index");
The third way: the return value in the controller is ModelAndView
return new ModelAndView("redirect:/toList");
2: Forward forward
For example:
request.getRequestDispatcher("/student_list.jsp").forward(request, response);
Recommended related articles and tutorials: java introductory tutorial
The above is the detailed content of How to implement page jump in java backend. For more information, please follow other related articles on the PHP Chinese website!