标签:ati str 文件中 info code oid public eth gas
切入的类和被切入的类必须是被spring管理的(springIOC),如果是自己new 出来的,切入无效,所以最好把它放在dispatcher-servlet.xml文件中。//切入类:
@Aspect
@Component
public class LoggingAspect {
private static final Logger logger = LoggerFactory.getLogger(LoggingAspect.class);
@After("execution(* com.hanming.oa.controller..*.*(..))")
public void afterMethod(JoinPoint joinPoint) {
String methodName = joinPoint.getSignature().getName();
String username = (String) SecurityUtils.getSubject().getSession().getAttribute("username");
logger.info(username + " ================= 执行 ================= " + methodName);
}
}
//使 Aspectj 注解起作用:自动匹配的类生成代理对象
<aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>
JavaEE_Spring_Aspect无法切入Controller层
标签:ati str 文件中 info code oid public eth gas
原文地址:http://blog.51cto.com/ltzbk/2065147