zoukankan      html  css  js  c++  java
  • 【报错问题】java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode

    情景:AOP获取请求参数,并转成JSON字符串时抛出

    原因

    ServletRequest,ServletResponse,MultipartFile不能被序列化,需要排除之后再做序列化。

    示例: 

    Object[] args = joinPoint.getArgs();
    Object[] arguments  = new Object[args.length];
    for (int i = 0; i < args.length; i++) {
      if (args[i] instanceof ServletRequest || args[i] instanceof ServletResponse || args[i] instanceof MultipartFile) {
                    //ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
                    //ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response
                    continue;
      }
       arguments[i] = args[i];
    }
    paramter = JSONObject.toJSONString(arguments);
  • 相关阅读:
    yum---Linux软件安装与管理
    Python Cheetah01
    Python 改变字体颜色
    DenyHosts安装及配置
    Python 文件I/O
    Python 列表(List)
    Python 字符串
    Python 循环语句
    Python 条件语句
    Python 系统性能信息模块psutil
  • 原文地址:https://www.cnblogs.com/stxyg/p/14964788.html
Copyright © 2011-2022 走看看