Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

spring is not redirecting to default target url?

I am using spring security for authentication. authentication is working fine. but after authentication it is not redirecting to the html that have mentioned using default target url in spring security configuration file. i am getting simple message Success. but not the html page that have configured. i have added below line for redirection.

<form-login login-page="/login.jsp" default-target-url="/welcome.html"/>

am i missing anything to configure.

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If a user is sent to the login page after requesting a protected resource, they will be sent to the originally requested page after successful login. The default-target-url will only be used if the user logged in without requesting a protected resource first (i.e. they navigated directly to the login page). If you always want to go to the default-target-url you can specify always-use-default-target="true" as shown in the example below

<form-login login-page="/login.jsp" 
            default-target-url="/welcome.html" 
            always-use-default-target="true"/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...