我想在 Spring (3.2.3) @Controller 中的每个方法之前运行一些代码。我定义了以下但它不会运行。我怀疑切入点表达式不正确。
调度器-servlet.xml
<aop:aspectj-autoproxy/>
<bean class="com.example.web.controllers.ThingAspect"/>
c.e.w.c.ThingAspect
@Pointcut("execution(com.example.web.controllers.ThingController.*(..))")
public void thing() {
}
@Before("thing()")
public void doStuffBeforeThing(JoinPoint joinPoint) {
// do stuff here
}
最佳答案
您的切入点表达式缺少返回类型,例如 void
、String
或 *
,例如
execution(* com.example.web.controllers.ThingController.*(..))
关于java - Controller 中所有方法的 Spring AOP 切入点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23607872/