且构网

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

用于Spring 4.0 + Security 3.2 + j_spring_security_check的JavaConfiguration

更新时间:2022-06-09 00:03:31

在3.2版本中,post参数已从j_username更改为username,而j_password更改为password.登录网址也已从/j_spring_security_check更改为/login.

In 3.2 version post parameters have changed from j_username to username and j_password to password. The login url has also changed from /j_spring_security_check to /login.

请参阅此链接以说明实施此更改的原因:

See this link for the explanation of why this change was implemented: http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#jc-httpsecurity. These are the changes:

  • GET/login呈现登录页面,而不是/spring_security_login

  • GET /login renders the login page instead of /spring_security_login

POST/login验证用户身份,而不是/j_spring_security_check

POST /login authenticates the user instead of /j_spring_security_check

username参数默认为username而不是j_username

The username parameter defaults to username instead of j_username

密码参数默认为password而不是j_password

The password parameter defaults to password instead of j_password

以下是登录表单的示例:

And this for an example of a login form: http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#jc-form