Home > Java > javaTutorial > body text

How to implement page jump in java backend

王林
Release: 2019-12-18 11:28:38
Original
5391 people have browsed it

How to implement page jump in java backend

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";
Copy after login

The second way: the return value in the controller is void

public void login(HttpServletRequest req, HttpServletResponse resp)
resp.sendRedirect("http://localhost:8080/index");
Copy after login

The third way: the return value in the controller is ModelAndView

return new ModelAndView("redirect:/toList");
Copy after login

2: Forward forward

For example:

request.getRequestDispatcher("/student_list.jsp").forward(request, response);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template