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 ...
随机推荐
- oracle各种用户登录的方式
Oracle有3种用户: system.sys.scott 1.system和sys的差别在与是否能创建数据库2.sys用户登录创建数据库,3.scott是给刚開始学习的人学习的用户.学习者能够用Sc ...
- Java设计模式——抽象工厂模式
抽象工厂模式也是创建模式,可以把它理解成创建工厂的工厂,这种模式也是我们经常使用的.在抽象工厂中的接口是用来创建工厂的,每个生成的工厂又都可以按照工厂模式创建其他对象. 举例说明: 创建Shape接口 ...
- A. And Matching
分析题目:这道题的题目是说给定一个2的幂次n,然后要求我们从0~n-1这n个数中不重复的挑选两个进行配对,要求配对后的每一对按位与之和为k: 而且k的话还是从0~n-1都有的: 既然题目都这样说了,那 ...
- [linux tips] puppet client ssl 证书过期
问题: [root@control-01 .ssh]# puppet agent -tv Warning: Unable to fetch my node definition, but the ag ...
- 攻防世界-MISC:a_good_idea
这是攻防世界高手进阶区的第十题,题目如下: 点击下载附件一,解压后得到一张图片,把图片放到kali用binwalk查看一下,果然包含了几个文件, 用命令把文件分离出来, 得到一个misc文件和一个压缩 ...
- Bugku CTF练习题---MISC---宽带信息泄露
Bugku CTF练习题---MISC---宽带信息泄露 flag:053700357621 解题步骤: 1.观察题目,下载附件 2.下载到电脑里发现是一个bin文件,二进制文件的一个种类,再看名称为 ...
- 【论文笔记】Federated Learning for Wireless Communications: Motivation, Opportunities, and Challenges(综述)
Federated Learning for Wireless Communications: Motivation, Opportunities, and Challenges Authors So ...
- java高级用法之:JNA中的Structure
目录 简介 native中的struct Structure 特殊类型的Structure 结构体数组作为参数 结构体数组作为返回值 结构体中的结构体 结构体中的数组 结构体中的可变字段 结构体中的只 ...
- Json序列化与反序列化导致多线程运行速度和单线程运行速度一致问题
紧跟上篇文章 十个进程开启十个bash后一致写入命令执行完毕之后产生了很多很多的文件,博主需要对这些文件同意处理,也就是说对几十万个文件进行处理,想了又想,单线程处理那么多数据肯定不行,于是乎想到了使 ...
- Vue3 与依赖注入
Vue3 与依赖注入 本文写于 2021 年 2 月 19 日 在 React 中,我们可以通过 context 与 useContext 实现单例.注入--等诸多特性. 详细请看上一篇文章:如何利用 ...