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 ...
随机推荐
- drf认证、权限、限流
认证Authentication(5星) 认证逻辑及编写步骤 逻辑 认证类:用来校验用户是否登录,如果登录了,继续往下走,如果没有登录,直接返回 编写步骤 -第一步:写一个类,继承BaseAuthen ...
- java实现sftp文件上传下载
/** * * @param filePath 文件全路径 * @param ftpPath 上传到目的端目录 * @param username * @param password * @param ...
- Unity—2D边缘检测(描边效果)
一.ShaderLab 1.Alpha值边缘检测 根据图片的Alpha值边缘判定,向内扩一段距离做边缘,颜色设置未描边颜色: 片元着色阶段,向上下左右四个方向做检测,有一个点的透明度为0,判定为边缘: ...
- 将mysql主从复制由ABB模式修改为ABC模式
最近遇到一个奇葩的需求,需要将mysql的主从复制模式由ABB修改为ABC,恰好这个mysql集群没有开启GTID,当时是在B上做了一次全量备份,然后使用该全量备份恢复C的方式进行的.做完之后在想有没 ...
- 代码源 BFS练习1
BFS练习1 http://oj.daimayuan.top/course/11/problem/147 题目 思路 四个方向进行BFS 注意:此题读写量大,cin会被卡 代码 #include &l ...
- HCIE笔记-第六节-CIDR与ICMP
项目部 58人 地址:194.2.3.128 /26 研发部 100人 地址: 194.2.3.0/25 市场部 27人 地址: 194.2.3.192/27 财务部 15人 地址:194.2.3.2 ...
- 2021.12.08 平衡树——FHQ Treap
2021.12.08 平衡树--FHQ Treap http://www.yhzq-blog.cc/fhqtreapzongjie/ https://www.cnblogs.com/zwfymqz/p ...
- 2021.08.05 P1340 兽径管理(最小生成树)
2021.08.05 P1340 兽径管理(最小生成树) P1340 兽径管理 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 重点: 1.离线化. 题意: 有n个点,m条边,每次加 ...
- 百度AI人脸检测——解析JSON 数据格式
1.了解一下 通常情况下,每个需要访问网络的应用程序都会有一个自己的服务器,我们可以向服务器提交数据,也可以从服务器上获取数据.不过这个时候就出现了一个问题,这些数据到底要以什么样的格式在网络上传输呢 ...
- .NET Core(.NET6)中gRPC注册到Consul
一.简介 上一篇文章介绍了.NET Core 中使用gRPC,在微服务中,我们通常要把服务做成服务注册,服务发现的方式,那么这里来说一下gRPC是如何注册到Consul中的. Consul的安装这里就 ...