简体   繁体   English

在Spring Security中登录后击中登录URL

[英]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. 上面的代码是在我的security-context.xml中定义的,因此成功登录后它会将我带到主页,但是登录后,如果通过地址栏我再次击中登录URL,那么它将抛出403错误页面及其说明禁止访问指定资源(访问被拒绝)。

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() 您已将\\ login上的访问级别设置为isAnonymous() ,因此一旦登录,便会遇到问题,例如: isAuthenticated()

Change login to 将登录更改为

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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