在使用@Aspect 注解进行AOP编程时,如果项目中使用到了spring mvc 那么如果你想使用AOP 来拦截controller层的方法时,你的AOP注解需要声明在dispatcher-servlet.xml中

与spring mvc的配置定义在一起!!!
如果修改完后 报如下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0'
请将
修改为1.8.9版本
或者将spring版本升级到4.3.5以上!!!
本文详细介绍了如何在Spring MVC项目中正确配置AOP,以便能够有效地拦截Controller层的方法。特别指出,@Aspect注解需要在dispatcher-servlet.xml文件中与Spring MVC配置一同声明。此外,还提供了针对特定错误的解决方案,例如当遇到BeanCreationException错误时,建议检查Spring版本并进行必要的升级。
1万+

被折叠的 条评论
为什么被折叠?



