簡體   English   中英

為什么選擇j_spring_security_check 404?

[英]Why j_spring_security_check 404?

我正在嘗試使用Spring安全性實現基於表單的身份驗證。 重定向工作正常:我的主頁面正常工作,對於http://localhost:8080/master/admin我被重定向到登錄頁面( http://localhost:8080/master/login/ ):

    <form action="j_spring_security_check" method="POST">
        <label for="username">User Name:</label>
        <input id="username" name="j_username" type="text"/>
        <label for="password">Password:</label>
        <input id="password" name="j_password" type="password"/>
        <input type="submit" value="Log In"/>
      </form>

but when I submit I get 404 on address: `http://localhost:8080/master/login/j_spring_security_check`

這是我的配置web.xml:

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/root-context.xml</param-value>
    </context-param>
    <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>

    <!-- Creates the Spring Container shared by all Servlets and Filters -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

我的root-context.xml(我重定向谷歌,以便我知道頁面存在於上下文中)

<sec:http auto-config="true">
    <sec:intercept-url pattern="/admin/**" access="ROLE_USER" />
    <sec:form-login login-page="/login/"
        authentication-failure-url="http://www.google.com" default-target-url="http://www.google.com" />
    <sec:logout logout-success-url="/logout" />
</sec:http>

<sec:authentication-manager>
    <sec:authentication-provider>
        <sec:user-service>
            <sec:user name="test" password="test" authorities="ROLE_USER, ROLE_ADMIN" />
            <sec:user name="testuser" password="testuserpassword"
                authorities="ROLE_USER" />
        </sec:user-service>
    </sec:authentication-provider>
</sec:authentication-manager> 

我已經失去了很多時間,嘗試不同的組合,但沒有運氣。 任何幫助表示贊賞!

我認為這可能是您的安全表格應該指出的事實

/master/j_spring_security_check

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM