- <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
- <sec:authorize ifAllGranted="ROLE_ADMIN,ROLE_USER">
- admin and user
- </sec:authorize>
- <sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_USER">
- admin or user
- </sec:authorize>
- <sec:authorize ifNotGranted="ROLE_ADMIN">
- not admin
- </sec:authorize>
- ifAllGranted,只有當前用戶同時擁有ROLE_ADMIN和ROLE_USER兩個權限時,才能顯示標籤內部內容。
- ifAnyGranted,如果當前用戶擁有ROLE_ADMIN或ROLE_USER其中一個權限時,就能顯示標籤內部內容。
- ifNotGranted,如果當前用戶沒有ROLE_ADMIN時,才能顯示標籤內部內容。
- <sec:accesscontrollist domainObject="${item}" hasPermission="8,16">
- <a href="message.do?action=remove&id=${item.id}">Remove</a>
- </sec:accesscontrollist>
- 我們將當前顯示的對象作爲參數傳入acl標籤,然後指定判斷的權限爲8(刪除)和16(管理),當前用戶如果擁有對這個對象的刪除和管理權限時,就會顯示對應的remove超鏈接,用戶纔可以通過此鏈接對這條記錄進行刪除操作。
相關SpringSecurity對於部分菜單隱藏的相關代碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.