我正在尝试使用Spring Security处理基于Ajax的登录系统并且它工作正常,直到我得到了我需要配置的另一个需求authentication-success-handler,因此一旦用户通过Spring安全性进行身份验证,我就可以进行一些后期处理.
之前我没有<form-login/>用于显示登录页面.我的登录部分是一个下拉列表,它是标题部分的一部分,对于整个应用程序是常见的.
这就是我尝试配置Spring安全性的方法
<http pattern="/customer/**" auto-config="true" use-expressions="true" authentication-manager-ref="customerAuthenticationManager">
<!--<http pattern="/customer/**" auto-config="true" use-expressions="true">-->
<intercept-url pattern="/customer/logon.html*" access="permitAll" />
<intercept-url pattern="/customer/denied.html" access="permitAll"/>
<intercept-url pattern="/customer" access="hasRole('AUTH_CUSTOMER')" />
<intercept-url pattern="/customer/" access="hasRole('AUTH_CUSTOMER')" />
<intercept-url pattern="/customer/*.html" access="hasRole('AUTH_CUSTOMER')" />
<intercept-url pattern="/customer/*/*.html" access="hasRole('AUTH_CUSTOMER')" />
<form-login login-processing-url="/customer/logon.html" login-page="/shop/home.html"
authentication-success-handler-ref="webshopAuthenticationSuccessHandler" />
<logout invalidate-session="true"
logout-success-url="/customer/home.html"
logout-url="/customer/j_spring_security_logout" />
<access-denied-handler error-page="/customer/denied.html"/>
</http>
Run Code Online (Sandbox Code Playgroud)
使用这些配置,当我点击具有正确凭据的登录按钮时,我收到HTTP 302错误
http://localhost:8080/shop/customer/logon.html 302 found
Run Code Online (Sandbox Code Playgroud)
不确定我究竟做错了什么?
<form id="login" method="post" accept-charset="UTF-8">
<input id="userName" type="text" name="userName" size="30" />
<button type="submit" class="btn">Login</button>
</form>
Run Code Online (Sandbox Code Playgroud)
var data = $(this).serializeObject();
$.ajax({
'type': …Run Code Online (Sandbox Code Playgroud)