NutzCN Logo
问答 Aop权限控制获取注解参数
发布于 2621天前 作者 hziee514 2111 次浏览 复制 上一个帖子 下一个帖子
标签:

使用AOP进行权限控制的时候,要指定角色名字,在MethodInterceptor执行的时候怎么获得注解设置的参数

实现注解:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Authorize {
String[] value();
String[] roles();
}

@IocBean
public class AuthorizeInterceptor implements MethodInterceptor {
public void filter(InterceptorChain chain) throws Throwable {
//这里怎么取到Authorize.roles?
}
}

2 回复
chain.getMethod().getAnnotion(Authxxx.class);

添加回复
请先登陆
回到顶部