【发布时间】:2018-08-22 23:01:02
【问题描述】:
注释
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
String value();
}
AOP
@Aspect
@Component
public class MyAspect {
@Around("@annotation(MyAnnotation)")
public Object aroundHandler(ProceedingJoinPoint joinPoint) throws Throwable {
...
}
控制器
@Controller
public class MyController {
@RequestMapping(value="/hello", method=RequestMethod.GET)
@ResponseBody
@MyAnnotation(value="hello")
public String hello() {
return "hello";
}
}
在上述情况下,我的 aop 不起作用...
它可以与@Controller 未注释的其他方法一起正常工作。
它适用于 aop 表达式和控制器方法。
控制器方法可以通过注解来使用aop吗?
【问题讨论】:
-
我把你丢在这里了
It works fine with other methods, which is not annotated by @Controller-And it works fine with aop expression and controller method你也能多贴一点代码吗?
标签: java spring annotations aop spring-aop