[quote]
<!--acegi tag- -->
<bean id="viewResolver"
class="...framework.web.velocity.VelocityViewResolver">
...
<property name="attributesMap">
<map>
<entry key="authz" value-ref="authzImpl"/>
</map>
</property>
</bean>
<bean id="authzImpl" class="org.acegisecurity.taglibs.velocity.AuthzImpl" />
[/quote]
Welcome back, $!authz.principal
#if($!authz.allGranted("ROLE_MODEL","ROLE_PLAYING"))
blah blah blah blah blah
#end
[url]http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/taglibs/velocity/Authz.html[/url]
<!--acegi tag- -->
<bean id="viewResolver"
class="...framework.web.velocity.VelocityViewResolver">
...
<property name="attributesMap">
<map>
<entry key="authz" value-ref="authzImpl"/>
</map>
</property>
</bean>
<bean id="authzImpl" class="org.acegisecurity.taglibs.velocity.AuthzImpl" />
[/quote]
Welcome back, $!authz.principal
#if($!authz.allGranted("ROLE_MODEL","ROLE_PLAYING"))
blah blah blah blah blah
#end
[url]http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/taglibs/velocity/Authz.html[/url]
本文介绍了一个使用Acegi Security框架中的Velocity模板引擎Taglib进行授权检查的例子。通过配置VelocityViewResolver和AuthzImpl bean, 实现了对用户角色的检查。当用户拥有ROLE_MODEL和ROLE_PLAYING角色时,将显示特定的内容。
368

被折叠的 条评论
为什么被折叠?



