2010-10-06 23 views

回答

5

请使用您的taglib下面的代码:

class MyTagLib { 

    def myTag = { attrs, body -> 
     if (SpringSecurityUtils.ifAnyGranted("ROLE_ADMIN,ROLE_SUPERVISOR")) { 
     // do your stuff... 
     } 
    } 
} 
+0

起初我还以为我应该创建SpringSecurityUtils一个实例,但它是一个静态的类。 感谢您的回复。这非常有帮助。 – tgarrey 2010-10-07 10:25:07

0

使用您的taglib下面的代码:

class MyTagLib { 
    def springSecurityService // injected by Spring 

    def myTag = { attrs, body -> 
     def loggedIn = springSecurityService.loggedIn 
    } 
} 
相关问题