gpt4 book ai didi

java - 发送重定向不会更改浏览器中的URL

转载 作者:行者123 更新时间:2023-12-01 18:30:01 25 4
gpt4 key购买 nike

我正在使用Spring MVC。我执行以下步骤


登录我的应用程序
删除浏览器cookie和缓存
刷新


当我删除浏览器cookie并进行刷新时,它会将我重定向到登录页面。但是,此登录页面是在API的响应中打开的(在开发人员控制台中),而不是实际的浏览器。

enter image description here

我想在浏览器中打开登录页面,我该怎么做?

   /**
* 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";

关于java - 发送重定向不会更改浏览器中的URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60181959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com