我想在用@Controller 注释的类中选择所有用@RequestMapping 注释的方法。
以下切入点定义工作正常......在某些情况下:
@within(org.springframework.stereotype.Controller)
and
@annotation(org.springframework.web.bind.annotation.RequestMapping)
问题是,一旦@Controller-annotated 类实现了某个接口,切入点就不再适用,并且方法不会被拦截。这甚至发生在我刚刚实现 java.io.Serializable 时。
例如,这不起作用,但只要我删除“ implements Serializable ”,它就会起作用:
@Controller
public class TestController extends BaseController implements Serializable {
@RequestMapping(value = "/test")
public String testAuth1(final Model model) {
return "test";
}
}
春季 XML 配置:
<aop:config>
<aop:pointcut id="handlerMethods"
expression="@within(org.springframework.stereotype.Controller) and @annotation(org.springframework.web.bind.annotation.RequestMapping)" />
<aop:aspect ref="handlerAdvice">
<aop:before method="interceptionMethod" pointcut-ref="handlerMethods" />
</aop:aspect>
</aop:config>
有什么想法吗?谢谢!