Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 春季安全。难以置信的行为_Java_Spring_Authentication_Spring Mvc_Spring Security - Fatal编程技术网

Java 春季安全。难以置信的行为

Java 春季安全。难以置信的行为,java,spring,authentication,spring-mvc,spring-security,Java,Spring,Authentication,Spring Mvc,Spring Security,我有非常奇怪的春季安全行为 安全配置: <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springfr

我有非常奇怪的春季安全行为

安全配置:

<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.1.xsd">
   <http use-expressions="true" >   

        <intercept-url pattern="/home.jsp" access="permitAll" /> 

        <intercept-url pattern="/*" access="isAuthenticated()"/> 


        <form-login login-page="/"
            authentication-failure-url="/loginFailed" default-target-url="/index" />
        <logout logout-success-url="/logOut" />
    </http>
    <authentication-manager>
        <authentication-provider ref="provider" /> 
    </authentication-manager>

</beans:beans>
如果在url
http://localhost:8080/ui/
(根应用程序url)I类型

第一项活动:

1输入正确的密码-->
http://localhost:8080/ui/index
在日志中,我看到
/index
IsAuthentificated()==true

2按注销-->
http://localhost:8080/ui/
且日志为空
IsAuthentificated()==false

3输入正确的密码-->
http://localhost:8080/ui/home.jsp?message=success+注销
,我在控制台中看到
/logout
IsAuthentificated()==true

4按注销-->转到
http://localhost:8080/ui/
且日志为空
IsAuthentificated()==false

5输入正确的密码-->转到
http://localhost:8080/ui/
且日志为空
IsAuthentificated()==false

我不明白spring security选择使用哪个控制器的规则


我认为spring调用了正确的servlet,但使用了错误的URL

我注意到您可能忘记添加以下配置

    <intercept-url pattern="/loginFailed" access="permitAll" /> 
    <intercept-url pattern="/" access="permitAll" /> 


或者至少所有与登录/错误页面相关的页面通常都应该免于验证。

iI在Spring security将重定向到
默认目标url
或您重定向以获得验证的页面后,看不到任何更改。如果希望始终转发到默认目标,请使用
始终使用default target=“true”
    <intercept-url pattern="/loginFailed" access="permitAll" /> 
    <intercept-url pattern="/" access="permitAll" />