错误信息:

nested exception is java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)] with root cause:
错误原因:

joinPoint.getArgs()返回的数组中携带有Request(HttpServletRequest)或者Response(HttpServletResponse)对象,导致序列化异常。

解决方案:

//aop中获取请求参数

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);

 

相关文章:

  • 2021-07-17
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2021-09-06
  • 2022-01-22
猜你喜欢
  • 2021-04-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2021-10-03
相关资源
相似解决方案