我试图在 Spring AOP 中实现 after-returning
并且基本实现工作正常:
public void afterExecution(JoinPoint jp){
System.out.println("Returning");
System.out.println("Returning from: " + jp.toString());
// How to get the return type object here?
}
如何获取上述方法中的返回类型对象?
这是我在上下文 xml 文件中添加的:
<aop:pointcut id="emplRet" expression="execution(java.lang.String com.model.Employee.get*())"/>
<aop:aspect ref="aspect">
<aop:after-returning pointcut-ref="emplRet" method="afterExecution"/>
</aop:aspect>
请指教。
最佳答案
你可以指定
returning="retVal"
在你的切入点表达式中添加一个参数到你的方法中。您必须在 after-returning
建议中引用绑定(bind)值 retVal
。
关于java - Spring AOP : Getting return types in after-returning method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24099961/