[英]Spring AOP pointcut not triggering
由于某些原因,我的切入点未触发。 注意:我使用的是Spring样式的方面,而不是AspectJ样式。
XML片段
<bean id="authenticationAspect" class="ssel.banking.security.AuthenticationAspect" />
<aop:config>
<aop:aspect ref="authenticationAspect">
<aop:pointcut id="interceptControllerInvocation"
expression="execution(* org.springframework.web.servlet.mvc.Controller+.handleRequestInternal(javax.servlet.http.HttpServletRequest, ..))
and args(request, ..)
and target(controller)"/>
<aop:around pointcut-ref="interceptControllerInvocation"
method="authenticationAdvice"/>
</aop:aspect>
</aop:config>
我的bean定义的类
import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class AuthenticationAspect {
public ModelAndView authenticationAdvice(ProceedingJoinPoint pjp, HttpServletRequest request, Controller controller) throws Throwable{
String URL = request.getRequestURL().toString();
String viewName = URL.substring(0, URL.length() - 4);
System.out.println(viewName);
return (ModelAndView) pjp.proceed();
}
}
我想念什么吗?
最有可能不是跨bean边界调用handleRequestInternal方法,而是从bean本身进行调用。 我想您正在使用AbstractController作为控制器的基础,并且可以看到handleRequest方法直接调用handleRequestInternal。
如果不使用方面编译器并更改类字节码,则无法检测该代码。 而且您可能不想使用库代码(AbstractController)来做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.