开发者

MethodInvocation always returns null from pointcut expression

I defined one pointcut like below:

<aop:pointcut id="getAllDataCut" expression=
   "execution(* com.example.test.getAllData(com.example test.User)) and args(usr)" />

When i call

final Object[] methodArgs= methodInvocation.getArguements();

i am getti开发者_运维技巧ng always null.

Please give some hints. Thanks in Advance


Since you know the arguments sent to the method, you can get them as parameter to your aspect method:

public void aspect(JoinPoint joinPoint, com.example.test.User user) {  
  // DO SOME THING WITH user  
}

if you want to add aspect for methods with different arguments, you can remove the args from the expression

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜