0

I have a Spring mvc controller with to methods:

@RequestMapping(value = "/method1", method = GET) 
public A method1() throws Exception 
{           
    return new A();
}

and

@RequestMapping(value = "/method2", method = GET) 
public int method2() throws Exception 
{           
    return -1;
}

I want to intercept these methods with an Aspect:

@Before("execution(** com.test.controller.*(..))")
public void startLog()
{
    System.out.println("START");
}

This aspect works ok with method1 and fails with method2. What I am doing wrong?

Plebios
  • 835
  • 1
  • 7
  • 17

1 Answers1

2

pointcut expression for methods in a particular package having @RequestMapping annotation:

@Before("execution(* com.test.controller.*.*(..)) && @annotation(org.springframework.web.bind.annotation.RequestMapping)")
    public void startLog()
    {
        System.out.println("START");
    }
akki
  • 423
  • 2
  • 12
  • Yes, I had an error with the double ** as a returned type. With this and the annotation it works ok. Thanks – Plebios Dec 15 '15 at 10:59