简体   繁体   中英

Hitting login url after logging in, in spring security

 <http use-expressions="true" auto-config="true">

         <!-- Restrict URLs based on role -->
        <intercept-url pattern="/login" access="isAnonymous()" />
        <intercept-url pattern="/register" access="isAnonymous()" />
        <intercept-url pattern="/save" access="isAnonymous()" />

        <intercept-url pattern="/**" access="isAuthenticated()" />
        <form-login login-page="/login" default-target-url="/home" authentication-failure-url="/login" />
    </http>

Above code is defined in my security-context.xml, so after successful log in it is taking me to home page, but after logging in, if through address bar I'm hitting the login url again, then it is throwing 403 error page with description Access to the specified resource (Access is denied) has been forbidden.

Please help, what to do?

You've set the access level to isAnonymous() on \\login so once you've logged in you have problems as they are now: isAuthenticated()

Change login to

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM