Spring boot Spring引导注销,然后登录重定向到错误的URL

Spring boot Spring引导注销,然后登录重定向到错误的URL,spring-boot,spring-security,logout,Spring Boot,Spring Security,Logout,因此,我添加了一个新的控制器方法,该方法可以在没有注销确认的情况下注销用户,如下所示: public String quickLogout (HttpServletRequest request, HttpServletResponse response) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth != null){

因此,我添加了一个新的控制器方法,该方法可以在没有注销确认的情况下注销用户,如下所示:

    public String quickLogout (HttpServletRequest request, HttpServletResponse response) {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth != null){
            new SecurityContextLogoutHandler().logout(request, response, auth);
        }
        return "redirect: /login?logout";
    }
这会按预期工作,并将用户注销,但每当调用此功能,并且我尝试重新登录时,都会指向此URL:
http://localhost:8080/%20/login?logout

它应该指向:
http://localhost:8080/

正常的先确认后登录的注销没有此错误,应用程序启动时的第一次登录也没有此错误。我使用的是基本的Spring安全登录,所以我不确定它为什么要这样做


想法?

在评论中向Bob Tang致敬:是的,重定向中使用了所有空格,因此:

return "redirect: /login?logout";
使用:


冒号和第一个正斜杠之间的空格会被用在其他地方,这会扰乱导航。

注销后是否尝试重定向到“/”?您应该返回“重定向:/”,而不是“返回”重定向:/login?logout;现在,在调用logout方法后尝试登录时,我会被引导到
http://localhost:8080/%20/
Aha,在“重定向:”之后应该没有空格,所以只需重定向:/这绝对是个问题。我能理解为什么会这样,但我还是不喜欢。感谢您的快速帮助!
return "redirect:/login?logout";