how to conditionally show jsp content to logged in users with Spring security

前端 未结 8 1997
旧时难觅i
旧时难觅i 2020-12-07 12:59

I want to show content to any user that is logged in and to hide if they are not logged in. I\'m using jsp\'s and spring security.

Obviously a home grown solution i

8条回答
  •  爱一瞬间的悲伤
    2020-12-07 13:10

    I've had success with the following:

        
            ">Login
        
        
            ">Logout
        
    

    New roles can be added without affecting the logic here.


    To bring this answer up to date with Spring Security 3, using the isAnonymous() and isAuthenticated() expressions have worked well in combination thus far to achieve the same thing. Here's an example:

    
        
    Username: Password:
    ">Logout

提交回复
热议问题