在使用切面的时候碰到一个问题,
在Controller方法上加上 注解,然后再添加了dispatchService 的 @PostConstruct 注解,如下:
@PostConstruct
public void findAllExeRequestMethods() {
final Map<String, Object> beans = getContext().getBeansWithAnnotation(ExeController.class);
for (final Map.Entry<String, Object> entry : beans.entrySet()) {
for (final Method method : entry.getValue().getClass().getDeclaredMethods()) {
final ExeRequest req = method.getAnnotation(ExeRequest.class);
if (null != req) {
final RequestType reqType = req.value();
getMethodMap().put(reqType, method);
services.put(reqType, entry.getKey());
}
}
}
}
然后,对其中的ExeRequest注解,进行切面处理
比如:
@around, @Before 等
会导致上面的方法中 method 的annotation 值为空,只要切面一加就会这样,本来打算对注解做处理的
现在只能另寻他路
还不明白原因在哪里
切面处理与ExeRequest注解冲突问题探究

在使用切面技术时遇到在Controller方法上加注解后,导致ExeRequest注解值为空的问题。分析了可能的原因并讨论了解决策略。
1314

被折叠的 条评论
为什么被折叠?



