如何在@before中将值作为响应返回,而不是移动到控制器(使用AOP)

时间:2015-10-29 14:25:50

标签: java spring-mvc aop

我使用AOP概念,调度员将调用发送到before advice方法。在那里,如何在没有进入控制器的情况下在建议方法之前返回值?

public Object cache(JoinPoint jointPoint, RedisCache redisCache) throws Throwable{
String data = getRedisService().getValue(redisKey);
if(data != null){return "hi";}
}

1 个答案:

答案 0 :(得分:0)

before advice

Before advice runs before a matched method execution

around advice

It has the opportunity to do work both before and after the method
executes, and to determine when, how, and even if, the method actually 
gets to execute at all