切面打印日志時,參數序列化異常
異常信息:It is illegal to call this method if the current request is not in asynchron
原因
joinPoint.getArgs()返回的數組中攜帶有Request或者Response對象,導致序列化異常

解決
Object[] args = joinPoint.getArgs(); Stream<?> stream = ArrayUtils.isEmpty(args) ? Stream.empty() : Arrays.asList(args); List<Object> logArgs = stream .filter(arg -> (!(arg instanceof HttpServletRequest) && !(arg instanceof HttpServletResponse))) .collect(Collectors.toList()); //過濾后序列化無異常 String string = JSON.toJSONString(logArgs);
