Login with Spring security using Ajax

后端 未结 3 1924
情书的邮戳
情书的邮戳 2020-12-18 07:40

I am trying to work on Ajax based login system using Spring Security and it was working fine, till I got with another requirement where I need to configure authenticat

3条回答
  •  [愿得一人]
    2020-12-18 08:16

    With the login form that is currently posted it cannot work, as a form like this is needed:

    
      

    The post needs to be done j_spring_security_check, and username and password need to be suplied in fields j_username and j_password, otherwise it won't work.

    I think you are getting a redirect to a login page.

    You can see where the redirect is going with the chrome debugger or firebug if using firefox.

    To approach this first get the rest of the config working with the default login page generated by spring security, by removing login-page="/customer/logon.html".

    Once this works you can add back the custom login page, but it needs to have the elements above.

    Also I believe you are trying to post a JSTL tag via ajax to the server? If it's true it won't work, otherwise can you edit the question.

    Try it step by step by first using the default login page, then with an ajax request with hardcoded values just for testing and then when this works with a custom login page.

提交回复
热议问题