It is illegal to call this method if the current request is not in asynchron

CATIA P3 V5-6R2023在Windows 11 23H2上的稳定安装与系统级配置指南 CATIA是高端制造业核心的三维参数化设计平台,其运行依赖严格的系统底层支撑。理解CATIA的BRep几何内核原理与Windows子系统(如WSL、Hyper-V)的协同机制,是保障建模稳定性与计算精度的技术前提。CATIA Run-Time Library和OpenGL硬件加速能力共同决定了曲面重建、螺纹建模等关键操作的可靠性;而.NET Framework 3.5、VC++ 2022运行库及显卡Studio驱动的精准匹配,则构成工业软件在Win11环境落地的工程基础。本文聚焦于航空、轨交、能源等领域高频 阅读详情

切面报错写法:

/*
@auther aa

@create_date 2019-12-24 15:15

@Desc 接口请求日志切面

**/

import com.alibaba.fastjson.JSON;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

@Aspect
@Component
public class WebLogAcpect {
    protected static final Logger logger = LoggerFactory.getLogger(WebLogAcpect.class);

    /**
     * 定义切入点
     * */
    @Pointcut("execution(* com.smcv.xyx.partOrder.manage.controller.view..*.*(..))")
    public void webLog(){}

    /**
     * 前置通知
     * */
    @Before("webLog()")
    public void doBefore(JoinPoint joinPoint)throws Exception{
        //接收到请求,打印请求内容
        ServletRequestAttributes attributes =(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        //记录请求内容
        logger.info("-------------log print start--------");
        logger.info("请求接口名:{},请求方式:{}",request.getRequestURI().toString(),request.getMethod());
//报错位置在此下方
//报错位置在此下方
//报错位置在此下方
        logger.info("请求参数:{}",JSON.toJSONString(joinPoint.getArgs()));

    }

    @AfterReturning(returning="ret",pointcut = "webLog()")
    public void doAfterReturning(Object ret)throws Exception{
        ServletRequestAttributes attributes =(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        //接收到响应,打印请求内容
        logger.info("请求接口:{}的响应为:{}",request.getRequestURI(),JSON.toJSONString(ret));
        logger.info("-------------log print end--------");

    }

}

因为:当请求中带有ServletRequest或ServletResponse时无法进行序列号,因而报错

【解决方式】

/*
@auther aa

@create_date 2019-12-24 15:15

@Desc 接口请求日志切面

**/

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

@Aspect
@Component
public class WebLogAcpect {
    protected static final Logger logger = LoggerFactory.getLogger(WebLogAcpect.class);

    /**
     * 定义切入点
     * */
    @Pointcut("execution(* com.smcv.xyx.partOrder.manage.controller.view..*.*(..))")
    public void webLog(){}

    /**
     * 前置通知
     * */
    @Before("webLog()")
    public void doBefore(JoinPoint joinPoint)  {
        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];
        }
        String paramter = "";
        if (arguments != null) {
            try {
                paramter = JSONObject.toJSONString(arguments);
            } catch (Exception e) {
                paramter = arguments.toString();
            }
        }
        logger.info("请求接口名:{}", joinPoint.getSignature().getName());
        logger.info("请求参数:{}", paramter);
    }

    @AfterReturning(returning="ret",pointcut = "webLog()")
    public void doAfterReturning(Object ret)throws Exception{
        ServletRequestAttributes attributes =(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        //接收到响应,打印请求内容
        logger.info("请求接口:{}的响应为:{}",request.getRequestURI(),JSON.toJSONString(ret));
        logger.info("-------------log print end--------");

    }

}

 

168、OIS光学防抖系统设计:陀螺仪标定、音圈马达驱动与滚珠式/悬丝式结构选型 本文总结了OIS光学防抖系统设计中的关键问题与解决方案。作者通过实际案例指出,陀螺仪标定需重视零偏、灵敏度和温度补偿问题,音圈马达驱动需采用电流环控制并优化相位补偿。在机械结构选型方面,滚珠式适合大角度补偿但存在回差问题,悬丝式精度高但受重力影响,需根据应用场景选择。系统联调建议从开环到闭环逐步验证,注意陀螺仪与驱动频率匹配。最后给出5条经验建议:关注陀螺仪信噪比而非分辨率、预留标定余量、重视机械结构公差、配备专业调试工具、协调OIS与电子防抖的分工配合。文章强调OIS调试需针对不同模组特性进行反复测试与标 阅读详情

相关推荐

在 Ansys Mechanical 中使用“螺栓工具”插件自动生成螺栓

在有限元分析 (FEA) 中,高效创建螺栓连接对于确保机械装配的结构完整性和性能至关重要。螺栓是连接组件不可或缺的一部分,它们在负载下的精确建模会影响整个系统。快速高效的螺栓建模使工程师能够快速优化设计,满足紧迫的期限,并通过为其他关键设计任务释放资源来提高整体生产力。此外,螺栓建模的精度可以最大限度地降低模型创建过程中出错的风险,这对于获得可靠和准确的分析结果至关重要。因此,在 FEA 中快速且无错误地创建螺栓连接对于高效、可靠和成功的工程结果至关重要。

jkh920184196的博客 3101

It is illegal to call this method if the current request is not in asynchronous mode

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 M...

3508

从X86到ARM:将VINS-Fusion-GPU和ego-planner迁移到Jetson Orin-NX时,我踩过的那些‘环境差异’坑

本文详细介绍了将VINS-Fusion-GPU和ego-planner从X86平台迁移到Jetson Orin-NX(ARM架构)时遇到的环境差异问题及解决方案。内容涵盖ARM与X86的架构差异、依赖管理、性能调优和硬件接口适配,特别强调了CUDA在ARM平台上的优化配置和内存访问技巧,帮助开发者高效完成跨平台迁移。

weixin_42647395的博客 119

toJSON抛出异常It is illegal to call this method if the current request is not in asynchronous mode

将不能进行序列化的入参对象过滤掉,只要留下我们所需数据即可。对于这里的joinPoint,我们只需要去除request和response对象即可。在使用AOP实现日志记录功能时,用到了JSON.toJSON()将joinPoint.getArgs()数据转换为Json串,运行时抛出异常。抛出该异常的主要原因是JSON.toJSON()转换数据时要求入参必须是。数据,如果入参不能序列化,则会抛出上述异常。

swlimuhao的博客 2460

Unity Spine 3.8 (URP) 踩坑(Shader报错修改)

提供了新思路,打算尝试一下URP。但美术使用的spine版本是3.8,项目用的Unity2021.3.11f1c2,直接导入spine URP包,shader报错:half4 不能转成 SurfaceData2D;Spine-Sprite-StandardPass-URP-2D.hlsl 也报这个错,也是同样的改法即可。今天搜索spine优化,看到一篇文章。

hrlr1230的博客 4565

S32K144 LPI2C Master/Slave模式配置与多设备通信实战

本文详细介绍了NXP S32K144微控制器中LPI2C模块的主从模式配置与多设备通信实战。内容涵盖硬件连接、引脚配置、主从模式深度设置、中断/DMA应用,并通过AT24C16 EEPROM、SHT30传感器等实例,解析了多设备通信中的地址切换、时序控制及常见问题排查技巧,帮助开发者高效实现基于LPI2C的稳定通信。

weixin_29158047的博客 269

切面打印日志时,参数序列化异常。It is illegal to call this method if the current request is not in asynchron ——————

1.AOP的日志拦截类中,抛出异常: 2.代码如下: package com.jimulian.iwuxi.common.aop; import com.alibaba.fastjson.JSON; import com.jimulian.iwuxi.common.annotation.OptLogAno; import com.jimulian.iwuxi.mapper.OptLogMapper; import com.jimulian.iwuxi.pojo.OptLog; import com.j

suixinsuoyu12519的专栏 574

仿真学习系列(四十七):Sigrity仿真之直流压降与电流密度

在现代电子设计中,电源网络的设计和分析对于保证电路的稳定性至关重要。直流压降(IR-Drop)和电流密度是评估电源网络性能的关键参数,尤其是在高频和高速电路中。它们直接影响到设备的工作稳定性与效率。通过Sigrity的仿真工具,可以深入分析和优化这些电源特性,从而确保系统的可靠性。 本节将介绍直流压降和电流密度的基本概念,以及如何在Sigrity中使用PowerDC模块进行相关仿真。

案例文章,高速信号 510

每日解惑:It is illegal to call this method if the current request is not in asynchron

项目场景: 提示:这里简述项目相关背景: 例如:项目场景:示例:通过蓝牙芯片(HC-05)与手机 APP 通信,每隔 5s 传输一批传感器数据(不是很大) 问题描述: 提示:这里描述项目中遇到的问题: 例如:数据传输过程中数据不时出现丢失的情况,偶尔会丢失一部分数据 APP 中接收数据代码: @Override public void run() { bytes = mmInStream.read(buffer); mHandler.obta

qq_33331448的博客 4382

AI Agent开发第84课-paddleocr-vl全网唯一最全本地化布署教程

本文详解 PaddleOCR-VL 本地化布署全过程,指出为何在真实生产环境中 PaddleOCR-VL 更稳定、更易部署、更贴近工程落地。同时还会详细比较与 DeepSeek-OCR 的核心差异,为全网独家介绍paddleocr-vl的本地部署实战指南。

打造全国最全的AI Agent开发知识领域的博客 5966

2026年MathorCup数学应用挑战赛大数据竞赛赛道A论文分享

本文基于250款啤酒的化学与感官数据,构建以化合物-感官关系为核心的风味解析框架。通过多输出偏最小二乘与稀疏多任务建模,实现化合物组成到感官强度的稳健映射,并分离连续预测与等级校准;结合Spearman相关网络与重复抽样稳定性分析,筛选各感官属性的关键候选化合物;在低维潜在空间中保留真实风格统计结构,生成Tripel、Kriek等风格的合理化合物谱,并实现Pils/Lager向Tripel的受约束迁移,确保缺陷指标不恶化。三问共享统一数据尺度与模型逻辑,形成可检验的“预测—解释—生成”闭环,强调化学合理性与

177

切面打印日志时,参数序列化异常。It is illegal to call this method if the current request is not in asynchron

切面打印日志时,参数序列化异常 异常信息:It is illegal to call this method if the current request is not in asynchron 原因 joinPoint.getArgs()返回的数组中携带有Request或者Response对象,导致序列化异常 解决 Object[] args = joinPoint.getArgs(); ...

hellodakee的博客 1万+

R语言机器学习算法实战系列(十三)随机森林生存分析构建预后模型 (Random Survival Forest)

本教程运用随机森林生存分析筛选与患者生存状态显著相关特征。该方法借随机森林这一强大机器学习算法,构建多棵决策树并集成结果,以提高生存分析准确性,识别关键生物标志物。接着,利用选定特征构建风险得分,将多个特征转化为单一数值,量化患者风险水平。之后,依据风险得分将患者分为高、低风险亚型,为临床治疗提供个性化指导。最后,通过分析时间依赖的 ROC 曲线评估模型长期预测能力。此曲线计算不同阈值下的真正例率与假正例率,在多个时间点评估,全面展现模型长期稳定性与准确性。

专注生信领域 2020

Aop 打印参数日志时,出现参数序列化异常。It is illegal to call this method if the current request is not in asynchron

Aop 打印参数日志时,出现参数序列化异常。It is illegal to call this method if the current request is not in asynchron

w36680130的博客 665

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

SpringBoot 上传文件记录日志报错:It is illegal to call this method if the current request is not in asynchronou

springboot 上传文件记录日志是报错It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false) 原因,因为Object[] args = joinPoint.getArgs();会得到多余的ServletR...

子冰吖的博客 7303

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncSt

源头 package jane.servlet; import java.io.IOException; import javax.servlet.AsyncContext; import javax.servlet.ServletException; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import

入梦镜 2075

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncS

场景 提示信息1: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false) 提示信息2: Request processing failed; nested exception is com.alibaba.fastjson.JSONException: write javaBean error, fastjson ve

enthan809882的博客 2304

AOP拦截日志类,抛异常:java.lang.IllegalStateException: It is illegal to call this method if the current reque...

AOP的日志拦截类中,抛出异常: java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode 主要原因:对方法的参数使用JSON.toJSONString(args[index])转换时,有异常抛...

weixin_30596165的博客 3069

How to use Asynchronous Servlets to improve perfor

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34029949的博客 142

java.lang.IllegalStateException: It is illegal to call this method if the current request is not in

package com.example.zhangwenbo.demo.web.servlet; import org.springframework.http.HttpRequest; import javax.servlet.AsyncContext; import javax.servlet.ServletException; import javax.servlet.annotat...

张文波的博客 2539

python学习笔记(二)

网络编程相关知识 Python Internet 模块 以下列出了 Python 网络编程的一些重要模块: 协议 功能用处 端口号 Python 模块 HTTP 网页访问 80 httplib, urllib, xmlrpclib NNTP 阅读和张贴新闻文章,俗称为"帖子" 119 nntplib FTP 文件传输 20 ftplib, urllib SMTP 发送邮件 25 smtplib P...

hbn1326317071的博客 183

AOP拦截日志报错llegalStateException: It is illegal to call this method if the current request is not in as...

原文链接:https://my.oschina.net/mengzhang6/blog/2395893 关于一次AOP拦截入参记录日志报错的梳理总结 将服务发布到tomcat中后,观察服务的运行状态以及日志记录状况; 发现有如下一个问题: 2018-10-31 16:20:10,701 [] INFO aspect.PayMethodLogAspectJ - rest 请求开始{154...

weixin_30555753的博客 263

Java It is illegal to call this method if the current request is not in asynchronou

废话不多说,一针见血,狠不狠你说了算!! public static Object filterParams(Object object){ if(object instanceof HttpServletRequest){ object = "请求格式为Request类型,实例化失败,已经转换为字符串:("+object.toString()+")"; } if(object instanceof HttpServletResponse){ obje

Tongyao 686
上一篇: swagger忽略显示字段
下一篇: Unable to find a single main class from the following candidates
芬芳酩酊
博客等级 码龄10年 35粉丝 108原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值