0
出於某種原因,我的切入點不會被觸發。 注意:我使用的是春天風格的方面,而不是AspectJ風格。Spring AOP的切點不觸發
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();
}
}
我失去了一些東西?
添加到什麼卓然Regvart說,如果'handleRequestInternal'不被跨越邊界豆(即它正從豆另一種方法被稱爲像'handleRequest'它不會被代理的,因爲它是一個叫折返呼叫。 – mkobit