首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

应用spring aop拦截action记录日志的时候,发现同时拦截了action中的getter,setter方法

2013-07-01 
使用spring aop拦截action记录日志的时候,发现同时拦截了action中的getter,setter方法?如何才能不让aop拦

使用spring aop拦截action记录日志的时候,发现同时拦截了action中的getter,setter方法?
如何才能不让aop拦截getter,setter方法?
还是在service层记录日志适合些?
[解决办法]
做一些逻辑排除,类似于这样


@Pointcut("!withincode(@org.junit.Test * demo..*(..))")
    public void notInTestMethod() {}
 
    @Pointcut("getStringFieldAnnotatedWithInjectInTheDemoPackage() && notInTestMethod()")
    public void getStringFieldAnnotatedWithInjectInTheDemoPackageAndNotInTestMethod() {}

[解决办法]
好像没有直接去掉方法的语法,关注一下;

可以换个思路,比如给非getter,setter方法加个前缀或是注解,然后再在Pointcut里过滤

热点排行