Goo*_*ose 7 java spring spring-mvc spring-aop pointcut
我想在Spring(3.2.3)@Controller中的每个方法之前运行一些代码.我有以下定义,但它不会运行.我怀疑切入点表达式是不正确的.
调度员servlet.xml中
<aop:aspectj-autoproxy/>
<bean class="com.example.web.controllers.ThingAspect"/>
Run Code Online (Sandbox Code Playgroud)
cewcThingAspect
@Pointcut("execution(com.example.web.controllers.ThingController.*(..))")
public void thing() {
}
@Before("thing()")
public void doStuffBeforeThing(JoinPoint joinPoint) {
// do stuff here
}
Run Code Online (Sandbox Code Playgroud)
在当前版本的Spring MVC中执行此操作的正确方法是通过a ControllerAdvice.
请参阅:使用@ControllerAdvice注释建议控制器
对于以前的版本,请参阅我的这个答案:https: //stackoverflow.com/a/5866960/342852
您的切入点表达式缺少返回类型,例如void,String或*
execution(* com.example.web.controllers.ThingController.*(..))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21815 次 |
| 最近记录: |