java - Spring Security - 始终重定向到default-target-url

标签 java xml spring debugging spring-security

即使登录成功,访问 url 时也总是重定向到 default-target-url 时遇到问题。当我第一次访问/clinic/administator/jabatan/时,它会将我重定向到登录页面,但主要问题是自动重定向或手动访问该网址总是重定向到/clinic/home。


Spring 安全配置:

<beans 
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:security="http://www.springframework.org/schema/security" 
    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/context
        http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.1.xsd">
    <!--auto-config="true"-->
    <security:http use-expressions="true" access-denied-page="/WEB-INF/view/error/access-denied.jsp">
        <security:intercept-url pattern="/index*" access="permitAll" />
        <security:intercept-url pattern="/resources/**" access="permitAll" />
        <security:intercept-url pattern="/administator/**" access="isAuthenticated()" />

        <security:form-login login-page="/index" default-target-url="/home" authentication-failure-url="/index?error=true" />
    </security:http>

    <context:component-scan base-package="com.syncbro.clinic" />
    <context:annotation-config />

    <bean id="userDetailsService" class="com.syncbro.clinic.service.impl.UserDetailsServiceImpl" autowire="byType" />
    <bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
        <property name="userDetailsService" ref="userDetailsService" />
    </bean>

    <security:authentication-manager>
        <security:authentication-provider ref="daoAuthenticationProvider" />
        <!--    <security:password-encoder hash="sha-256" />
        </security:authentication-provider>-->
    </security:authentication-manager>

</beans>


Spring Security 调试:

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository  - Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT: 'org.springframework.security.core.context.SecurityContextImpl@94bed677: Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository  - Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT: 'org.springframework.security.core.context.SecurityContextImpl@94bed677: Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 2 of 8 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 2 of 8 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 3 of 8 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 3 of 8 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 4 of 8 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'

INFO: 14 Jul 2013 12:56:25,364 104661 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 4 of 8 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'

INFO: 14 Jul 2013 12:56:25,374 104671 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 5 of 8 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'

INFO: 14 Jul 2013 12:56:25,374 104671 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 5 of 8 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'

INFO: 14 Jul 2013 12:56:25,374 104671 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.authentication.AnonymousAuthenticationFilter  - SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR'

INFO: 14 Jul 2013 12:56:25,374 104671 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.authentication.AnonymousAuthenticationFilter  - SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR'

INFO: 14 Jul 2013 12:56:25,374 104671 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 6 of 8 in additional filter chain; firing Filter: 'SessionManagementFilter'

INFO: 14 Jul 2013 12:56:25,374 104671 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 6 of 8 in additional filter chain; firing Filter: 'SessionManagementFilter'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 7 of 8 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 7 of 8 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 8 of 8 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ at position 8 of 8 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/administator/jabatan/'; against '/index*'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/administator/jabatan/'; against '/index*'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/administator/jabatan/'; against '/resources/**'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/administator/jabatan/'; against '/resources/**'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/administator/jabatan/'; against '/administator/**'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/administator/jabatan/'; against '/administator/**'

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - Secure object: FilterInvocation: URL: /administator/jabatan/; Attributes: [isAuthenticated()]

INFO: 14 Jul 2013 12:56:25,394 104691 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - Secure object: FilterInvocation: URL: /administator/jabatan/; Attributes: [isAuthenticated()]

INFO: 14 Jul 2013 12:56:25,404 104701 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR

INFO: 14 Jul 2013 12:56:25,404 104701 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR

INFO: 14 Jul 2013 12:56:25,404 104701 [http-thread-pool-8080(3)] DEBUG org.springframework.security.access.vote.AffirmativeBased  - Voter: org.springframework.security.web.access.expression.WebExpressionVoter@57cabdca, returned: 1

INFO: 14 Jul 2013 12:56:25,404 104701 [http-thread-pool-8080(3)] DEBUG org.springframework.security.access.vote.AffirmativeBased  - Voter: org.springframework.security.web.access.expression.WebExpressionVoter@57cabdca, returned: 1

INFO: 14 Jul 2013 12:56:25,404 104701 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - Authorization successful

INFO: 14 Jul 2013 12:56:25,404 104701 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - Authorization successful

INFO: 14 Jul 2013 12:56:25,404 104701 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - RunAsManager did not change Authentication object

INFO: 14 Jul 2013 12:56:25,404 104701 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - RunAsManager did not change Authentication object

INFO: 14 Jul 2013 12:56:25,414 104711 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ reached end of additional filter chain; proceeding with original chain

INFO: 14 Jul 2013 12:56:25,414 104711 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.FilterChainProxy  - /administator/jabatan/ reached end of additional filter chain; proceeding with original chain

INFO: 14 Jul 2013 12:56:25,424 104721 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.ExceptionTranslationFilter  - Chain processed normally

INFO: 14 Jul 2013 12:56:25,424 104721 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.access.ExceptionTranslationFilter  - Chain processed normally

INFO: 14 Jul 2013 12:56:25,424 104721 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed

INFO: 14 Jul 2013 12:56:25,424 104721 [http-thread-pool-8080(3)] DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed

INFO: 14 Jul 2013 12:56:25,565 104862 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'

INFO: 14 Jul 2013 12:56:25,565 104862 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'

INFO: 14 Jul 2013 12:56:25,575 104872 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository  - Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT: 'org.springframework.security.core.context.SecurityContextImpl@94bed677: Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR'

INFO: 14 Jul 2013 12:56:25,575 104872 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository  - Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT: 'org.springframework.security.core.context.SecurityContextImpl@94bed677: Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR'

INFO: 14 Jul 2013 12:56:25,575 104872 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 2 of 8 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'

INFO: 14 Jul 2013 12:56:25,575 104872 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 2 of 8 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'

INFO: 14 Jul 2013 12:56:25,575 104872 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 3 of 8 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'

INFO: 14 Jul 2013 12:56:25,575 104872 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 3 of 8 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'

INFO: 14 Jul 2013 12:56:25,575 104872 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 4 of 8 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'

INFO: 14 Jul 2013 12:56:25,575 104872 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 4 of 8 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 5 of 8 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 5 of 8 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.authentication.AnonymousAuthenticationFilter  - SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.authentication.AnonymousAuthenticationFilter  - SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@94bed677: Principal: org.springframework.security.core.userdetails.User@586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMINISTRATOR; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: bbf2cc6aac40b722885672e0853a; Granted Authorities: ROLE_ADMINISTRATOR'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 6 of 8 in additional filter chain; firing Filter: 'SessionManagementFilter'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 6 of 8 in additional filter chain; firing Filter: 'SessionManagementFilter'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 7 of 8 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 7 of 8 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 8 of 8 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home at position 8 of 8 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/home'; against '/index*'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/home'; against '/index*'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/home'; against '/resources/**'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/home'; against '/resources/**'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/home'; against '/administator/**'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.util.AntPathRequestMatcher  - Checking match of request : '/home'; against '/administator/**'

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - Public object - authentication not attempted

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor  - Public object - authentication not attempted

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home reached end of additional filter chain; proceeding with original chain

INFO: 14 Jul 2013 12:56:25,585 104882 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.FilterChainProxy  - /home reached end of additional filter chain; proceeding with original chain

INFO: 14 Jul 2013 12:56:25,606 104903 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.access.ExceptionTranslationFilter  - Chain processed normally

INFO: 14 Jul 2013 12:56:25,606 104903 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.access.ExceptionTranslationFilter  - Chain processed normally

INFO: 14 Jul 2013 12:56:25,606 104903 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed

INFO: 14 Jul 2013 12:56:25,606 104903 [http-thread-pool-8080(2)] DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed

最佳答案

我认为由于第一个拦截url规则匹配并且它需要permitAll角色;。

<security:intercept-url pattern="/index*" access="permitAll" />

您的登录页面 URL 还包含“/index”。

<security:form-login login-page="/index" default-target-url="/home" authentication-failure-url="/index?error=true" />

由于“/index”URL需要身份验证和授权,因此再次重定向到登录页面; 也许您可以更改第一个条目的拦截 URL 模式,然后重试。

关于java - Spring Security - 始终重定向到default-target-url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17636980/

相关文章:

xml - ColdFusion 问题 : Reading Value of XML Child as Empty String

xml - 将属性值的 XML 序列转换为字符串?

java - 改变现有颜色 OpenGL 的方法

Java字符串分割不一致

c# - 调用 format-number XPath 函数时,收到错误 : "Namespace Manager or XsltContext needed."

Spring 数据: How to query a subtype using a specification

java - 将对象的新实例注入(inject)每个请求处理程序

java - 如何始终在 Mapbox android 中显示信息窗口而无需单击标记?

java - JTabbedPane:从其他类调用选项卡

java - Spring boot 不明确的处理程序