我知道有很多問題已經可用,與此錯誤有關,但我已嘗試幾乎所有事情,沒有任何修復我的問題。彈簧安全使用AJAX登錄時顯示403錯誤
當我sumbmitting我在瀏覽器控制檯的形式,我看到
Failed to load resource: the server responded with a status of 403 (Forbidden)
我的項目是在Spring 4.0.3,春季安全4.0.1,Java的8和wildfly 8.x的服務器
上運行我的Ajax調用
$.ajax({
url: "j_spring_security_check",
data: $('#loginForm').serialize(),
type: "POST",
beforeSend: function (xhr) {
xhr.setRequestHeader("X-Ajax-call", "true");
},
success: function(result) {
if (result == "not-ok") {
$('.error').show();
$('.login-error').html(CREDENTIAL_CHECK) ;
return false;
} else {
$('.error').hide();
document.location = result;
}
},
error: function(XMLHttpRequest, textStatus, errorThrown){
$('.error').show();
$('.login-error').html(NETWORK_CHECK) ;
return false;
}
});
我的安全配置:
<security:form-login login-page="/home"
default-target-url="/home"
authentication-failure-handler-ref="myAuthenticationFailureHandler"
authentication-success-handler-ref="myAuthenticationSuccessHandler"
/>
<security:logout logout-success-url="/logout"
invalidate-session="true"
delete-cookies="SPRING_SECURITY_REMEMBER_ME_COOKIE"
/>
我試圖設置
<security:headers disabled="true" />
<security:csrf disabled="true" />
它不working.in服務器控制檯還,我沒有看到任何錯誤。
我還能做些什麼來解決這個錯誤?我已經浪費了2天這個問題
鏈接'login'不'j_spring_security_check'。 –
你好嗎? – user3035305
檢查你的控制器中的ajax url是否存在。並確保您的控制器中的RequestMethod.POST。 –