赞
踩
@Component
@Aspect
public class WebControllerAop {
@Pointcut("execution(* cn.sky.controller.*..*.*(..))")
public void executeService() {
}
@Around(value="executeService()")//好的
// @Around(value="executeService()&&(args(request,..) || args(..,request))")//好的
// @Around(value="executeService()&&(args(..,request,response)||args(request,response,..))")//好的
public Object doAroundAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Exception {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
Signature signature = proceedingJoinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature)signature;
Method targetMethod = methodSignature.getMethod();
Method realMethod = proceedingJoinPoint.getTarget().getClass().getDeclaredMethod(signature.getName(), targetMethod.getParameterTypes());
Object obj = proceedingJoinPoint.proceed();
return obj;
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。