简体   繁体   English

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

[英]send redirect does not change URL in browser

I am using Spring MVC.我正在使用 Spring MVC。 I do the following steps我执行以下步骤

  1. Login into my application登录我的应用程序
  2. delete browser cookies and cache删除浏览器 cookie 和缓存
  3. do a refresh刷新一下

When I delete browser cookies and do a refresh it redirects me to the login page.当我删除浏览器 cookie 并进行刷新时,它会将我重定向到登录页面。 But this login page is opened in the response of the API (in developers console) and not the actual browser.但是这个登录页面是在 API 的响应中打开的(在开发者控制台中)而不是实际的浏览器。

在此处输入图片说明

I want to open the login page in the browser, how do I do that ?我想在浏览器中打开登录页面,我该怎么做?

   /**
 * 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM