JSON.toJSONString(joinPoint.getArgs())报错getOutputStream() has already been called for this response
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
private void addOperationLog(JoinPoint joinPoint, Object res, int time) {
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
MpOpLog operationLog = new MpOpLog();
operationLog.setRunTime(time);
operationLog.setReturnVal(JSON.toJSONString(res));
System.out.println("================:"+joinPoint.toString());
Object[] args = joinPoint.getArgs();
Object[] arguments = new Object[args.length];
System.out.println("================:"+args);
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();
}
}
System.out.println("================:"+paramter.toString());
operationLog.setArgs(paramter.toString());
operationLog.setOpTime(new Date());
operationLog.setMethod(signature.getDeclaringTypeName() + "." + signature.getName());
String uerid = AppUtil.getJwtParam("userId");
String userName = AppUtil.getJwtParam("userName");
operationLog.setUserId(StringUtils.defaultIfBlank(uerid, "anonymous"));
operationLog.setUserName(StringUtils.defaultIfBlank(userName, "anonymous"));
OpLog annotation = signature.getMethod().getAnnotation(OpLog.class);
if (annotation != null) {
operationLog.setId(UUID.randomUUID().toString().replace("-", ""));
operationLog.setLevel(annotation.level());
operationLog.setContent(getDetail(((MethodSignature)joinPoint.getSignature()).getParameterNames(),
arguments, annotation));
operationLog.setOpType(annotation.operationType().getValue());
operationLog.setOpUnit(annotation.operationUnit());
}
tmpOpLogService.insert(operationLog);
}
JSON.toJSONString(joinPoint.getArgs())报错getOutputStream() has already been called for this response的更多相关文章
- 【转】JSON.parse() Unexpected token i in JSON at position 2 报错问题
JSON.parse(): Unexpected token i in JSON at position 2 报错问题 错误代码: var res = "[{id:1,name:'limin ...
- C# String.Format格式化json字符串中包含"{" "}"报错问题
json.Append(String.Format("{\"total\":{0},\"row\":{1}}", lineCount, st ...
- 后台返回json字符串 页面js报错 Uncaught SyntaxError: Unexpected identifier
后台json字符串是 [{"name": "报销申请", "id": "start"}, {"name&quo ...
- 利用json模块解析dict报错找不到attribute 'dumps'[python2.7]
[背景] 环境: RHEL 7.3 版本: python2.7 [错误情况] 写了一个简单的python脚本 将dict转换为json 脚本如下: #!/usr/bin/python #-*- cod ...
- 【微信】微信小程序 微信开发工具中新创建的json文件,编译报错VM1781:2 pages/module/module.json 文件解析错误 SyntaxError: Unexpected end of JSON input
如果新创建报错:编译报错VM1781:2 pages/module/module.json 文件解析错误 SyntaxError: Unexpected end of JSON input 解决方法 ...
- JSON.parse解决Unexpected token ' in JSON at position 1报错
壹 ❀ 引 我们知道JSON.parse能将JSON字符串转变成JS对象,但在一些转换中可能出现Unexpected token ' in JSON at position 1的错误,这是因为被转换 ...
- Unexpected token o in JSON at position 1 报错原因
写在前面的话这个问题在之前做项目时碰到过一次,当时按照网上的做法,去掉JSON.parse()这一层转换后就没有这个报错了,数据也能正常使用,就没多想,也没深究是什么原因. 可是这次又碰到了,所以这次 ...
- struts2使用json返回数据,报错:Parent package is not defined: json-default - [unknown location]
使用struts2的struts-json插件时,一直报错:找不到json-default的位置,下面是我的查错步骤: 1.将struts-json版本更改为低版本,结果还是报这个错 2.重新导入ma ...
- PHP“Cannot use object of type stdClass as array” (php在调用json_decode从字符串对象生成json对象时的报错)
php再调用json_decode从字符串对象生成json对象时,如果使用[]操作符取数据,会得到下面的错误 错误:Cannot use object of type stdClass as arra ...
随机推荐
- spring程序开发步骤
1.使用spring框架之前的开发步骤 2.使用spring之后的开发步骤 3.文字描述 1.导入Spring开发的基本依赖 2.编写Dao接口和实现类 3.创建spring核心配置文件 4.在spr ...
- Kubernetes 解决方案-图解
- 简简单单用一下 Hbase
一.Hbase 介绍 https://hbase.apache.org/book.html#_preface https://blogs.apache.org/hbase/ https://resea ...
- Color Constancy 颜色恒定性
1:Color Constancy? 世界上并不存在颜色.颜色仅仅是我们的眼睛和大脑对不同可见光的波长进行的一层映射.也就说颜色只是我们大脑和视网膜处理的结果. 1.1 关键问题 我们的视觉系统有一个 ...
- 学习打卡——Linux下安装Redis
http://download.redis.io/releases/,这是查看当前Redis可供下载的Linux系统版本 第一步:启动系统 启动Linux,我这里是CentOS 7 第二步:下载 打开 ...
- 在边缘计算场景中使用Dapr
Dapr 是分布式应用程序可移植.事件驱动的运行时, 这里有几个关键字,我们拆开来看一下: 分布式: 代表共享或是分散,在云原生应用上体现为微服务,在边缘计算场景中代表分散的模块,可以做积木式拼接. ...
- 2021.11.16 P2375 [NOI2014] 动物园(EXKMP+差分)
2021.11.16 P2375 [NOI2014] 动物园(EXKMP+差分) https://www.luogu.com.cn/problem/P2375 题意: PS:这道神题的背景让人疑惑,重 ...
- 最大数maxnumber - 题解【树状数组】
原题: 现在请求你维护一个数列,要求提供以下两种操作: 1. 查询操作.语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度. 2. 插入操作.语法 ...
- k8s入门之pod(四)
pod是k8s项目中的最小编排单位,它是运行中的一组(一个或多个)容器,这些容器共享存储.网络.调度等资源,pod是一个逻辑概念,同一个名称空间下不同pod可以通过ip互相访问. 一.通过命令行方式管 ...
- PicLite 开发日志 v0.0.2
PicLite 开发日志 (v0.0.2) 感谢您阅读本片文章! Gitee 地址:https://gitee.com/XiaoQuQuSD/pic-lite. 新增功能 添加复制 url 的格式选项 ...