我希望使用AspectJ获取HTTPServletRequest并记录其中的一些值,但JoinPoint中得到的是一个“RequestFacade”对象。这个对象似乎无法提供太多有用的信息。我的日志策略是否出错?如何从HttpServletRequest中获取有用的信息?如果在调用方法之前必须解包它,那么这就有点违背了我的应用程序中AOP的目的。
我正在使用Glassfish服务器,不知道这是否有所影响。
我正在使用Glassfish服务器,不知道这是否有所影响。
@Before("execution(* Service.testAuditRecord(..))")
public void logBefore(JoinPoint joinPoint) {
System.out.println("logBefore --->" + joinPoint.getSignature().getName());
System.out.println("logBefore--->Args : " + Arrays.toString(joinPoint.getArgs()));
}
RequestFacade记录
INFO: logBefore --->testAuditRecord
INFO: logBefore--->Args : [org.apache.catalina.connector.RequestFacade@4dbfa7d0]