Spring security custom login page

In the project, we certainly can't use the login page generated by spring, but use our own login page. Let's talk about how to customize the login page. Let's take a look at the configuration first

Use the form login configuration to specify our own configuration file, where

Login page: login page

Authentication failure URL: the page to jump to after login failure

Default target URL: the page to jump to after successful login

In the login page

The form submission address is: J_ spring_ security_ check

The name of the user name is: J_ username

The name of the password is: J_ password

The submission method is post

After restarting tomcat, open the project again and find that the login page has become our own login page, as shown in the following figure

If the error of page circulation is prompted because the login page does not need to be verified because it is not set, add the following configuration

After entering the user name and password, we jump to the page specified by us

Note: restarting Tomcat sometimes does not invalidate the session. It may occur during testing. When Tomcat is restarted to access resources, it does not jump to the login page. So you need to restart the browser and try again.

summary

The above is the spring security custom login page introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>