Skip to content

Commit

Permalink
SpringSecurity退出功能的实现并自定义退出的url
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglufei committed Apr 11, 2022
1 parent f983d7f commit a239d8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/com/uin/config/SpringSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ protected void configure(HttpSecurity http) throws Exception {
.userDetailsService(userDetailsService)
//持久层对象
.tokenRepository(persistentTokenRepository);

//退出功能
http.logout()
//自定义退出的url
.logoutSuccessUrl("/login.html");
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

<form action="/login" method="post">
用户名:<input type="text" name="username" placeholder="请输入用户名">
用户名:<span type="text" name="username" placeholder="请输入用户名">
用户名:<input type="text" name="username" placeholder="请输入用户名">

密码:<input type="password" name="password" placeholder="请输入密码">
记住我:<input type="checkbox" name="remember-me" value="true">
<button type="submit">登陆</button>
<a href="/logout">退出</a>
</form>
</body>
</html>

0 comments on commit a239d8c

Please sign in to comment.