开发者

MethodInvocation always returns null from pointcut expression

开发者 https://www.devze.com 2023-02-01 00:08 出处:网络
I defined one pointcut like below: <aop:pointcut id=\"getAllDataCut\" expression= \"execution(* com.example.test.getAllData(com.example test.User)) and args(usr)\" />

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

精彩评论

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