赞
踩
- package com.cloud.aop;
-
- import lombok.extern.slf4j.Slf4j;
- import org.aspectj.lang.ProceedingJoinPoint;
- import org.aspectj.lang.annotation.Around;
- import org.aspectj.lang.annotation.Aspect;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
-
- import javax.servlet.http.HttpServletRequest;
- import java.util.Date;
-
- @Component
- @Slf4j
- @Aspect
- public class Aop {
- @Autowired
- HttpServletRequest request;
- //aop 的注解 ,用于指定要环绕的方法的匹配规则.
- //这里表示要环绕com.cloud.controller包下所有类的所有方法
- @Around(value = "execution(* com.cloud.controller.*.*(..))")
- public Object log(ProceedingJoinPoint joinPoint) throws Throwable {
- //获取请求方式
- String method = request.getMethod();
- //获取请求ip地址
- String remoteAddr = request.getRemoteAddr();
- //获取请求路径
- String requestURI = request.getRequestURI();
- //当前时间
- Date date = new Date();
- log.debug("method:"+method);
- log.debug("remoteAddr:"+remoteAddr);
- log.debug("requestURI:"+requestURI);
- log.debug("date:"+date);
- return joinPoint.proceed();
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。