春季安全.对于不同角色的同一页面的不同视图,可能吗?

use*_*011 3 java security roles spring-security web

例如,我们有Book List页面.

此页面包含书籍列表.

如果用户角色="ADMIN"显示在页面按钮"删除书籍"或类似"编辑书".

如果用户角色="SIMPLY_USER",则用户无法看到任何类似"删除.."或"编辑..."的按钮.

快速查看Spring Security 3之后 - 我无法找到适用于我的案例的任何实现.

是真的?

Arn*_*lay 12

您可以使用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>
Run Code Online (Sandbox Code Playgroud)

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