loginPage与loginProcessingURL有什么区别?
.formLogin().loginPage("/login").usernameParameter("phone-number").passwordParameter("password")
似乎是loginProcessingURL就像post方法,一旦用户在登录页面中提交了数据,但是当我删除它时也可以正常工作。 loginProcessingURL的意义是什么?它与loginPage有何区别?
答案 0 :(得分:2)
第loginPage("/login")
行指示Spring Security
AND
.loginProcessingUrl("/login/process")
当发送指定路径时,告诉Spring Security处理提交的凭据,并且默认情况下,将用户重定向回来自的页面用户。 它不会将请求传递给Spring MVC和您的控制器。
答案 1 :(得分:-1)
Spring安全源代码中的以下代码段可能对您有帮助:
loginPage the login page to redirect to if authentication is required
loginProcessingUrl the URL to validate username and password
DEFAULT_LOGIN_PAGE_URL = "/login"
/**
* Updates the default values for authentication.
*
* @throws Exception
*/
protected final void updateAuthenticationDefaults() {
if (loginProcessingUrl == null) {
loginProcessingUrl(loginPage);
}
//...
}