更新时间:2023-12-04 18:42:10
在您的示例中,您不需要控制器(LoginController.java)来处理安全性,Spring Security会为您完成.删除此代码.
In your example you don't need a controller (LoginController.java) to handle security, Spring Security does it for you. Remove this code.
在AngularJs中,您需要发送POST请求才能登录.像这样:
In AngularJs you need to send a POST request to login. Like this :
var data = "username="+username+"&password="+password+"&submit=Login";
$http({
method: 'POST',
url: $window.domaineName + 'j_spring_security_check',
data: data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
}
})
.success(function(data, status){
//login success
})
.error(function(data, status){
// login failure
})
要注销,您需要发送另一个Http POST请求:
In order to logout, you need to send another Http POST request :
$http({
method: 'POST',
url: $window.domaineName + 'j_spring_security_logout',
})
.success(function(data, status){
// logout success
})
.error(function(data, status){
// logout failure
})