2016-08-17 82 views
-5

我想僅在成功登錄後才顯示用戶主頁。Spring Security僅在成功登錄後纔會顯示主頁

我的意思是,當有人會點擊「ht'tp:// localhost:8081/example」這樣的應用程序的URL時,我想將他重定向到「ht'tp:// localhost:8081/example/login 「並且只有在登錄後,用戶纔會看到默認的主頁,它將在」url/example「上,他可以在其中執行某些操作或註銷。

使用示例從mkyong http://www.mkyong.com/spring-security/spring-security-hibernate-annotation-example/

沒有找到堆棧上的答案,也許有人會幫助我這個。

+2

你能解釋一下你在實施這個過程中遇到的問題嗎? –

+0

這個實現沒有問題,但我想部署應用後,當imhiting localhost:8081/example重定向到登錄頁面時。 – Hipeq

回答

1

嘗試將.defaultSuccessUrl("url/example", true)添加到安全配置中的HttpSecurity對象。這應該導致用戶在成功登錄後總是被重定向到給定的頁面。

相關問題