且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

spring security 4 自定义登录页面

更新时间:2021-07-23 09:58:51

您将登录页面配置为 /login.html(使用 loginPage("/login.html")).这也将更改您需要发布登录凭据的位置.文档指出:

You configured your login page to be at /login.html (using loginPage("/login.html")). This will also change the location to which you need to post the credentials to login. The documentation states:

如果/authenticate"被传递给这个方法[loginPage(String)],它会将默认值更新为如下图:

If "/authenticate" was passed to this method [loginPage(String)] it update the defaults as shown below:

  • /authenticate GET - 登录表单
  • /authenticate POST - 处理凭据,如果有效则对用户进行身份验证
  • /authenticate?error GET - 重定向到此处进行失败的身份验证尝试
  • /authenticate?logout GET - 成功注销后重定向到这里

为了使登录工作,您需要使 login.html 将凭据发布到 /login.html 而不是 /login>.

In order to make the login work, you need to make login.html post the credentials to /login.html instead of /login.