Follow through progressive 04 maven Response redirection

Redirect:

 

 

 

 

B after a web resource receive client requests A, B he will notify the client A to access another web resource C, this process is called redirection

Common scenario:

 ·User login

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

resp.sendRedirect("/r/image");//重定向

// resp.sendRedirect Split 
// resp.setHeader ( "the Location", "/ r / Image");
// resp.setStatus (302);
// interview questions: Can you talk about the difference between redirection and forwarding?
// same point
// 1. page will realize jump
// different points
// 1. When forwarding the request, url will not change
// 2. Redirect time, url address bar will change


}

Guess you like

Origin www.cnblogs.com/huhao2000/p/11940659.html