[英]send redirect does not change URL in browser
我正在使用 Spring MVC。 我執行以下步驟
當我刪除瀏覽器 cookie 並進行刷新時,它會將我重定向到登錄頁面。 但是這個登錄頁面是在 API 的響應中打開的(在開發者控制台中)而不是實際的瀏覽器。
我想在瀏覽器中打開登錄頁面,我該怎么做?
/**
* Handles requests related to security of the application.
*/
@Controller
public class SecurityController {
@Resource(name = "syncService")
private SyncService syncService;
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(ModelMap model , HttpServletResponse res) {
res.setHeader("URL", "Login");
return "login";
}
@RequestMapping(value = "/403", method = RequestMethod.GET)
public String acd(ModelMap model) {
return "403";
}
@RequestMapping(value = "/next", method = RequestMethod.GET)
public String next(ModelMap model) {
return "next";
}
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logout(ModelMap model, HttpServletRequest request) {
HttpSession session = request.getSession();
session.invalidate();
/* model.addAttribute("mess","you have been logged out"); */
return "login";
}
@RequestMapping(value = "/accessdenied", method = RequestMethod.GET)
public String loginerror(ModelMap model) {
model.addAttribute("error", "true");
return "denied";
}
}
嘗試
return "redirect:/login";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.