springboot:logout参数未被eleaf模板获取

gdx19jrr  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(213)

好的,所以当用户注销时,它会将他们返回到sign-in.html页面,但是我想要显示的消息不会显示。它应该显示“you have been logged out.”,但由于某些原因,该参数没有被捕获/识别。我已经尝试了所有我能想到的方法来解决这个问题,但是它不会显示消息。知道为什么吗?
编辑:param.error消息有效,我可以通过添加.logoutsuccessurl(“/sign-in?error”)让它显示该消息,但对于“/sign-in?logout”它不起作用。
这是我的配置:

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/"
                        , "/home"
                        , "/sign-up"
                        , "/css/style.css"
                        , "/scripts/scripts.js"
                        , "/images/*").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginPage("/sign-in").permitAll()
                .defaultSuccessUrl("/welcome", true)
                .and()
                .httpBasic()
                .and()
                .logout()
                .logoutSuccessUrl("/sign-in?logout")
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                .invalidateHttpSession(true)
                .deleteCookies("JSESSIONID")
                .and()
                .rememberMe().key("uniqueAndSecret")
                .tokenValiditySeconds(1800);
    }

这是my sign-in.html:

<section id="main-content">

            <div class="container">
                <div class="row">
                    <div class="col-lg-auto col-md-auto col-sm-auto form-col sign-in-div">
                        <h3 class="sign-in-header">Sign in to your account</h3>
                        <form class="lusu-form" id="sign-in" th:action="@{/sign-in}" th:object="${returningUser}" method="post">
                            <p class="form-error" th:inline="text" th:if="${returningUser.alreadyExists}">
                                Account with email [[${returningUserForm.email}]] already exists. Please sign in.
                            </p>
                            <p class="form-error" th:inline="text" th:if="${param.error}">
                                The username and password combination entered returned no results. Please try again.
                            </p>
                            <p class="form-error" th:inline="text" th:if="${param.logout}">
                                You have been logged out.
                            </p>
                            <div class="form-group">
                                <label for="exampleInputEmail1">Email address</label>
                                <input type="email" name="username" class="form-control" id="exampleInputEmail1"
                                    th:field="*{username}" required>
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1">Password</label>
                                <input type="password" name="password" class="form-control" id="exampleInputPassword1"
                                    required>
                            </div>
                            <button type="submit" class="btn btn-dark submit-button">Submit</button>
                        </form>
                    </div>
                </div>
            </div>
        </section>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题