我有一个Spring mvc控制器,带有to方法:
@RequestMapping(value = "/method1", method = GET)
public A method1() throws Exception
{
return new A();
}
和
@RequestMapping(value = "/method2", method = GET)
public int method2() throws Exception
{
return -1;
}
我想用一个方面拦截这些方法:
@Before("execution(** com.test.controller.*(..))")
public void startLog()
{
System.out.println("START");
}
此方面在method1
中工作正常,在method2
中失败。我做错了什么?
具有@RequestMapping注释的特定包中方法的切入点表达式:
@Before("execution(* com.test.controller.*.*(..)) && @annotation(org.springframework.web.bind.annotation.RequestMapping)")
public void startLog()
{
System.out.println("START");
}