Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.5k 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 Reply

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"/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...