Get method arguments using Spring AOP?

后端 未结 8 2004
陌清茗
陌清茗 2020-11-29 01:13

I am using Spring AOP and have below aspect:

@Aspect
public class LoggingAspect {

    @Before(\"execution(* com.mkyong.customer.bo.CustomerBo.addCustomer(..         


        
8条回答
  •  难免孤独
    2020-11-29 01:45

    Yes, the value of any argument can be found using getArgs

    @Before("execution(* com.mkyong.customer.bo.CustomerBo.addCustomer(..))")
    public void logBefore(JoinPoint joinPoint) {
    
       Object[] signatureArgs = thisJoinPoint.getArgs();
       for (Object signatureArg: signatureArgs) {
          System.out.println("Arg: " + signatureArg);
          ...
       }
    }
    

提交回复
热议问题