java.lang.IllegalStateException: It is illegal to call this method if the current request is not in
2021/7/2 20:51:22
本文主要是介绍java.lang.IllegalStateException: It is illegal to call this method if the current request is not in,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
情景:AOP获取请求参数,并转成JSON字符串时抛出
原因:
ServletRequest,ServletResponse,MultipartFile不能被序列化,需要排除之后再做序列化。
示例:
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]; } paramter = JSONObject.toJSONString(arguments);
这篇关于java.lang.IllegalStateException: It is illegal to call this method if the current request is not in的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南