简体   繁体   English

如何根据 JSF 中的用户角色隐藏一些内容?

[英]How can I hide some content based on user role in JSF?

I'm using JAAS and have applied security on some folders for different roles.我正在使用 JAAS 并为不同角色的某些文件夹应用了安全性。 I want to hide some navigation for different users because, although the pages are not accessible, the user can still see the links that he has no rights on?我想为不同的用户隐藏一些导航,因为虽然页面不可访问,但用户仍然可以看到他没有权限的链接? What's the simple way to achieve this in JSF?在 JSF 中实现这一目标的简单方法是什么? Do I need to call a method to check the role in the "rendered" property of each navigation link?我是否需要调用一个方法来检查每个导航链接的“rendered”属性中的角色? Any sample code?任何示例代码? Please help!请帮忙!

Use rendered for view, take使用rendered视图,取

rendered="#{userBean.role =='ADMIN'}"

also configure filter or use Spring security's filter to restrict them to access the URL还可以配置过滤器或使用 Spring security 的过滤器来限制他们访问 URL

正确的答案在这里,可能对其他人有帮助: “isUserInRole”方法与 JAAS 相关吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM