RT 用AOP记录日志 哪个用户 什么时间 做了什么操作
解决方案 »
- Spring3 + JPA2:诡异的单元测试调用service空指针错误
- 框架
- 为什么接受到session值为NULL
- 困惑中,应该如何学习Struct?
- 方法加锁问题
- 如何解析下面的字符串阿?。。。。。。。。。。。。
- 怎样将XML文件导入到ORACLE数据库中,谢谢了。。。
- java调用c编写的dll中方法时出错,EXCEPTION_ACCESS_VIOLATION occurred at PC=0x2,帮帮忙!
- 在tomcat5下能调用批处理吗~~
- java工程中密码配置相关疑问
- hibernate annotation oracle nvarchar2 类型映射
- struts的action标签没有调用相应的action,该怎么解决?
<bean name="logManager" class="com.study.spring.aop.LogManager"></bean>
<bean name="LogTestService" class="com.study.spring.aop.service.impl.LogTestServiceImpl"></bean>
<aop:config>
<aop:aspect ref="logManager">
<aop:pointcut id="logAOP" expression="execution(* com.study.spring.aop.service.impl.LogTestServiceImpl.say(..))"/>
<aop:after method="printLog" pointcut-ref="logAOP"/>
</aop:aspect>
</aop:config>
package com.study.spring.aop;import org.aspectj.lang.JoinPoint;public class LogManager{ public void printLog(JoinPoint joinpoint) throws Exception{
Object[] objs = joinpoint.getArgs();
for(Object obj : objs){
System.out.println(obj);
}
System.out.println("spring aop test.");
}
}//test
package com.study.spring.aop;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;import com.study.spring.aop.service.LogTestService;public class Test { public static void main(String[] args) throws Exception {
ApplicationContext act = new ClassPathXmlApplicationContext("applicationContext.xml");
LogTestService service = (LogTestService)act.getBean("LogTestService");
try {
service.say(1);
} catch (RuntimeException e) {
e.printStackTrace();
}
}
}//service
package com.study.spring.aop.service;public interface LogTestService { public int say(int i);
}
//impl
package com.study.spring.aop.service.impl;import com.study.spring.aop.service.LogTestService;public class LogTestServiceImpl implements LogTestService{ public int say(int i){
System.out.println("hello world!");
return 1;
}
}