I was trying to implement after-returning
in Spring AOP and the basic implementation works fine:
public void afterExecution(JoinPoint jp){
System.out.println("Returning");
System.out.println("Returning from: " + jp.toString());
// How to get the return type object here?
}
How to get the return type object in the above method?
This is what I added in the context xml file:
<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>
Please advice.
You can specify
returning="retVal"
in your pointcut expression and add a parameter to your method. You would have to reference the bound value retVal
in your after-returning
advice.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.