2012-02-12 33 views
3

例如,我們有Book List頁面。Spring Security。不同角色的同一頁面的不同視圖,可能嗎?

此頁面包含書籍列表。

如果用戶角色=「ADMIN」顯示頁面按鈕「刪除書籍」或類似「編輯書籍」。

如果用戶角色=「SIMPLY_USER」用戶看不到任何按鍵喜歡「刪除..」或「編輯...」。

在快速瀏覽Spring Security 3之後 - 我無法找到任何實現我的情況。

這是真的嗎?

回答

11

您可以在jsp中使用spring security taglib根據用戶角色決定顯示哪些內容。

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> 

<sec:authorize access="hasRole('supervisor')"> 

This content will only be visible to users who have 
the "supervisor" authority in their list of <tt>GrantedAuthority</tt>s. 

</sec:authorize> 

參考:http://static.springsource.org/spring-security/site/docs/3.0.x/reference/taglibs.html

+0

大,謝謝! – user471011 2012-02-12 12:57:27