How springmvc redirect the process?

If the login is successful, the system will be redirected to the home page response.sendRedirect ( "jsp / frame.jsp"); in the springmvc What should I do? It can be used directly return "frame"; redirected to the page?

In general, the controller method returns the string will be treated as a logical view of it, this is only awakened server page jump only, not new client resends the request url, if you want to redirect operation, it is necessary to add redirect: prefix , springmvc will it special treatment, will redirect: as an indicator, followed by a string url treatment. as follows

@RequestMapping(value = "/dologin.html", method = RequestMethod.POST)
public String doLogin(@RequestParam String userCode, @RequestParam String userPassword){
    //省略
    return "redirect:/user/main.html";
    //response.sendRedirect("jsp/frame.jsp");
}

 

Guess you like

Origin www.cnblogs.com/yanguobin/p/11665146.html