I have the following pointcut defined, which works great.
@Pointcut("args(req, resp) && (execution(org.springframework.web.servlet.ModelAndView org.springframework.web.servlet.mvc.Controller+.*(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)))")
However, if I change it to the following pointcut, removing the response variable and replacing it with ..
:
@Pointcut("args(req) && (execution(org.springframework.web.servlet.ModelAndView org.springframework.web.servlet.mvc.Controller+.*(javax.servlet.http.HttpServletRequest, ..)))")
The pointcut does not have any markers and never gets executed, strangely.
Any idea why this would be happening?
This is due to the first part of your composed pointcut i.e args(req). It matches a method which takes a single argument.
The second part i.e
execution(org.springframework.web.servlet.ModelAndView org.springframework.web.servlet.mvc.Controller+.*(javax.servlet.http.HttpServletRequest, ..))
matches a method which has at least one argument of type HttpServletRequest.
However Controller interface method handleRequest takes two arguments.
Change this part args(req)
of the pointcut to args(req,..)
@Pointcut("args(req,..) && (execution(org.springframework.web.servlet.ModelAndView org.springframework.web.servlet.mvc.Controller+.*(javax.servlet.http.HttpServletRequest, ..)))")