1
class MyController {
def index() { }
def list(Integer max) { }
def create() { }
}
控制器我有一個像「管理員」,「用戶」 不同的角色,我想,只有「管理員」看「創建」視圖。知道我使用春季安全
class MyController {
def index() { }
def list(Integer max) { }
def create() { }
}
控制器我有一個像「管理員」,「用戶」 不同的角色,我想,只有「管理員」看「創建」視圖。知道我使用春季安全
documentation是非常明確的如何解決這個問題。使用通過數據庫的請求映射來鎖定URL或使用註釋。
如果您使用的是請求映射,則只需鎖定特定角色集的URL即可。如果你想鎖定myController的地方創建視圖只提供給管理員,這將是
configAttribute: ROLE_ADMIN url: /myController/create/**
如果使用註釋這將是
class MyController {
@Secured(['ROLE_ADMIN'])
def create() { }
}
閱讀寫得很好documentation以獲取更多信息。
非常感謝你 工作完美 – kokio
Upvote爲RTFM回答:) –