2012-02-23 20 views

答えて

21

はあなたのUserDetailsオブジェクトを参照するため、そのオブジェクトを検査すると、ロールはpublic Collection<GrantedAuthority> getAuthorities() { .. }に格納されます。 JSPからgetAuthoritiesを使用する方法

<sec:authentication property="principal.authorities"/> 
18

getAuthoritiesを使用するか、独自のuserdetailsの実装を作成し、便利なメソッドを作成します。

か:hereから

<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> 

+0

- :あなたは、単に画面上の役割を印刷したい場合は、言っ

は、これを行いますか? – Rajesh

+0

ノーマル・ビーン・コンベンションを使用する: NimChimpsky

+0

URLは現在動作しません。 –

3
<sec:authentication property="principal.authorities" var="authorities" /> 
<c:forEach items="${authorities}" var="authority" varStatus="vs"> 
<p>${authority.authority}</p> 
</c:forEach> 
+0

少しの細部は長い道のりです... –

関連する問題