读书人

应用spring aop拦截action记录日志的时

发布时间: 2013-07-01 12:33:04 作者: rapoo

使用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里过滤

读书人网 >J2EE开发

热点推荐