Spring security login always lands in an error page with no message

后端 未结 6 1344
夕颜
夕颜 2020-12-16 06:22

I\'m using a login form for a small project in Spring but I have a small problem which is that every time I log in using a sign in form I get an error redirection.

T

6条回答
  •  庸人自扰
    2020-12-16 06:44

    You can add the always-use-default-target param to the success URL.

    .defaultSuccessUrl("/home",true)
    

    This means that if the login is successful you will always be sent to /home.

    I think the undesirable behaviour is caused by the error page being queued for some reason, and then when the login is successful you get "returned" to that.

    This isn't the ideal solution but providing you don't want to go to the previous page after logging in, then it works to prevent your described behaviour.

提交回复
热议问题