我试图在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>
请建议。
答案 0 :(得分:2)
您可以指定
returning="retVal"
在你的切入点表达式中并为你的方法添加一个参数。您必须在retVal
建议中引用绑定值after-returning
。
答案 1 :(得分:0)