我有一个@After
运行某些逻辑的java方面。我需要它返回一个结果(一个对象),该结果可以在方面切入点拦截的方法中使用。是否可以?
你需要的是@Around
它允许您将想要的任何内容返回给建议的对象:
@Around("com.xyz.myapp.UserService.createUser()")
public Object userCreationAdvice(ProceedingJoinPoint pjp) throws Throwable {
//Do something if needed before method execution
Object retVal = pjp.proceed();
//Do something if needed after method execution
return retVal;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)