Spring 3 Security j_spring_security_check

后端 未结 3 1159
星月不相逢
星月不相逢 2021-02-13 17:12

I\'m trying to learn, how spring security works, so I\'ve downloaded some sample project and then I tried to implement that solution to my project. But when I try to login, I ge

相关标签:
3条回答
  • 2021-02-13 17:27
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>
            org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    

    Add your web.xml File .Its Create Bean of Your springSecurityFilterChain .Then you Got Response

    0 讨论(0)
  • 2021-02-13 17:28

    You are trying to validate to a uri based on the current context path of the web page. the JSTL tag lib can be used to ensure you easily generate the correct urls based on the context of the application. You can do this by using a tag library if you want to get it implemented quickly. To do this you can add the jstl tag library to the top of the jsp:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    

    Then you can use the following to post to the login servlet.

    <form action="<c:url value="/j_spring_security_check"></c:url>" method="post" role="form">
    

    This ensures you alway post to <your_application_context>/j_spring_security_check.

    reference for jstl: http://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/c/url.html

    0 讨论(0)
  • 2021-02-13 17:51

    The path /j_spring_security_check has changed to /login in spring 4 and it is handled in UsernamePasswordAuthenticationFilter

    You can find it's source here: https://github.com/spring-projects/spring-security/blob/master/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilter.java

    0 讨论(0)
提交回复
热议问题