在springSecurity.xml文件中开启注解支持,springSecurity中默认是关闭的:
<security:global-method-security jsr250-annotations=“enabled”/>
在pom文件中添加依赖:
javax.annotation
jsr250-api
1.0
然后在方法上使用注解的过程中@RolesAllowed({“ROLE_ADMIN”})注解不起作用,权限不受控制,有登陆权限的人都可以访问任意资源。
解决方法:将@RolesAllowed({“ROLE_ADMIN”})从controller层移到service层,问题就得到解决。
具体原因:没想清楚。欢迎补充,解释
security中jsr250不生效解决办法
最新推荐文章于 2023-03-28 11:00:59 发布