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

5g LDPC编译码-LDPC编码 本文摘要:LDPC编码是5G业务信道的核心编码技术,属于线性分组码。5G中LDPC编码分为两种基图类型(BG1和BG2),通过码块分割、CRC处理等步骤实现。编码过程主要涉及校验矩阵生成和校验位计算,其中校验矩阵采用稀疏矩阵结构。文中详细介绍了5G LDPC编码的具体实现流程,包括码块分割规则、校验位生成方法,以及两种基图(BG1和BG2)在矩阵结构和参数设置上的差异,重点阐述了通过模块化方法求解校验比特位的技术路径。 阅读详情

切面报错写法:

/*
@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--------");

    }

}

 

Python 爬虫实战:全国高校录取分数线数据爬取与院校对比分析 本文介绍了一个基于Python的高考志愿填报辅助系统,通过爬取掌上高考平台的全国高校录取分数线数据,构建本地数据库并实现智能分析。系统主要功能包括:1)使用requests+BeautifulSoup爬取院校基本信息和历年分省分科类录取线;2)通过SQLite实现数据持久化与增量更新;3)利用pyecharts生成分数线趋势图、院校对比雷达图等可视化图表;4)提供"冲稳保"三档智能选校推荐。技术栈涵盖网络爬虫、数据清洗、数据库管理和可视化分析,可为考生提供数据驱动的志愿填报决策支持。项目采用模块化设计,包含 阅读详情

相关推荐

glm-4v-9b环境配置全攻略:从CUDA版本冲突到bitsandbytes异常排查(RTX A4000实测)

本文详细介绍了在RTX A4000显卡上配置GLM-4V-9B多模态大模型的完整流程,重点解决CUDA版本冲突和bitsandbytes异常问题。通过4-bit量化技术显著降低显存占用,提供从环境预检到量化部署的实战指南,帮助开发者在有限显存环境下高效运行大模型。

weixin_30369041的博客 405

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

从SolidWorks到URDF:插件使用、关节配置与PyBullet仿真避坑指南

本文提供了一份从SolidWorks导出URDF模型并导入PyBullet进行仿真的完整实战指南。详细讲解了SolidWorks插件的正确安装与配置、关节类型的选择与坐标系对齐的核心技巧,并针对PyBullet仿真中常见的模型散架、路径错误、物理属性异常等问题提供了深度避坑解决方案,帮助机器人开发者高效完成从设计到仿真的全流程。

weixin_29081101的博客 542

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

多目标优化NSGA-II(快速精英非支配排序遗传算法)及python实现

文章目录前言一、什么是NSGA-II?二、学习NSGA-II1.快速非支配排序算法2.密度估计3.拥挤比较算子4.主循环5.代码6.总结 前言 NSGA-II适用于复杂的多目标优化问题,是K-Deb教授在2000年在一篇paper《MOEAs — A fast and elitist multi-objective genetic algorithm: nsga2》提出。 Keywords: optimization; multi-objective evolutionary algorithm; no

ricky_blog 9744

RK3588与FPGA高速PCIe通信:从理论带宽到实战优化的全流程解析

本文深入解析了瑞芯微RK3588与FPGA之间基于PCIe Gen2的高速通信全流程。从理论带宽计算(约1640MB/s)出发,详细拆解了硬件连接、驱动加载、DMA配置等关键步骤,并重点分享了中断优化、内存管理及高级调优等实战技巧,旨在帮助开发者从“跑通”到“跑好”,实现接近理论极限的稳定高效数据传输。

weixin_29175469的博客 332

切面打印日志时,参数序列化异常。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

人形机器人硬件开发:骨架系统设计全攻略

本文以人形机器人骨架系统为核心研究对象,系统解析其从理论建模到工程实现的全流程设计方法。通过融合刚体力学、材料科学与机器人控制理论,构建"概念基础-理论框架-架构设计-实现机制-实际应用-高级考量-综合拓展"的七层分析体系。重点覆盖运动学/动力学建模、轻量化结构设计、关节模块集成、多物理场耦合优化等关键技术,结合波士顿动力Atlas、本田ASIMO等经典案例,提供从原型设计到量产验证的工程实践指南。

AI天才研究院 1876

每日解惑: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

Arcgis中的模型构建器技术之按属性批量建库并对应输出

好久没更新了,之前我们已经介绍过四至点提取模型,前两天有同事问怎么样按属性批量建数据库并对应输出相关图斑。比如将一个县的永农数据按乡镇建立数据库并将对应乡镇的永农数据输出到相应的数据库里。今天就介绍一下相关的模型构建过程。

weixin_44671081的博客 518

VS2019编译使用log4cplus 1.2.0

logger.properties 文件。第三步,创建项目来测试,配置库。第二步,使用VS2019编译。

h a 6 6 6 c k 为 你解决复杂难题! 527

切面打印日志时,参数序列化异常。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万+

星敏感器:卫星姿态测量的“星空导航仪”

在卫星、航天器和深空探测器的姿态控制系统中,星敏感器(Star Tracker) 是最精确的姿态测量设备之一。它通过识别恒星的位置,计算出航天器在惯性空间中的三轴姿态,精度可达 角秒级(arcsecond),是许多高精度任务(如遥感、天文观测、深空探测)的核心传感器。

ScilogyHunter的博客 3695

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

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

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

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

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

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

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、付费专栏及课程。

余额充值