一、需要了解注解:@Aspect、@Pointcut、@Around
@Aspect:定义为切面
@Pointcut:定义切点
@Around:定义环绕的方法(逻辑处理在这)
二、直接上代码
切面:
package com.taox.txshop.modules.testtao.config;
import com.taox.txshop.base.glscommon.dto.Result;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class TaoApoTest {
@Pointcut(value = "execution(public * com.taox.txshop.modules.testtao.TestTaoController.test31(..))")
public void point(){
}
@Around("point()")
public Result<String> around(ProceedingJoinPoint proceedingJoinPoint){
//取方法参数
Object[] args = proceedingJoinPoint.getArgs();
String str = (String) args[0];