Spring MVC 角色和管理员权限 [英] Spring MVC Role and Permission to Admin

查看:32
本文介绍了Spring MVC 角色和管理员权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 spring mvc 的新手,在我现有的项目中,有一个管理员,他们有权更新数据,但现在我需要创建 2 个新管理员,admin1 和 admin2登录时只能看到有限的页面,例如:

I am new in spring mvc , In my existing project , there is one admin and they have rights to update data , but now i need to create 2 new admin , admin1 and admin2 that can only see limited page when they login like:

当管理员登录时,他们可以在菜单栏中看到添加数据、更新数据、发布消息页面.但在 Admin1 的情况下,只能在菜单栏中看到 Post meassage 页面.

when admin login , they can see Add data, update data, Post message pages in menu bar. but in case Admin1 , can see only Post meassage page in menu bar.

所以,请指导我如何在 spring mvc 中完成此任务提前致谢.

so, please guide me how can i achieve this task in spring mvc Thanks in Advance.

推荐答案

你必须考虑使用Spring security来实现这个.检查以下内容

you have to consider using Spring security to achieve this.check the following

<http auto-config="true">
 <intercept-url pattern="/admin*" access="ROLE_ADMIN" />
</http>

这意味着,只有具有ROLE_ADMIN"权限的用户才能访问 URI/admin*.如果非授权用户尝试访问它,将显示http 403 访问被拒绝页面".

It means, only user with authority of "ROLE_ADMIN" is allowed to access URI /admin*. If non authorized user try to access it, a "http 403 access denied page" will be displayed.

你必须配置 urls 和允许访问它们

you have to configure the urls and the allowed access to them

http://www.mkyong 上的简单示例.com/spring-security/spring-security-access-control-example/

这篇关于Spring MVC 角色和管理员权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆