Cannot call sendError() after the response has been committed 错误记录
来源:互联网 发布:代替淘宝指数的软件 编辑:程序博客网 时间:2024/06/03 18:03
Cannot call sendError() after the response has been committed 错误记录
在使用Spring MVC开发过程中遇到了一个十分迷惑的错误 Response has been committed。
通过打断点,发现代码都正常运行通过,但是就是一直报这个错,于是仔细观察代码发现有段代码中对象引用形成了一个循环,如下代码:
JSONObject result = new JSONObject(); Person person = new Person(); person.setId(1); person.setName("张三"); List<Person> personList = new ArrayList<Person>(); personList.add(person); person.setPersonList(personList); result.put("person", person);
后来发现,原来是通过jackson转化为Json数据的时候,发现了一个循环引用,jackson无限循环转化,最终栈溢出,导致问题出现。
而在jackson不同版本下的错误信息也不同,在1.9.4版本下错误信息为:
Handling of [org.springframework.http.converter.HttpMessageNotWritableException] resulted in Exceptionjava.lang.IllegalStateException: Cannot call sendError() after the response has been committed...(以下省略)
在2.2.1版本下的错误信息为:
org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: Infinite recursion (StackOverflowError) (through reference chain: java.util.ArrayList[0]->com.unuse.diary.api.Person["personList"]->java.util.ArrayList[0]->com.unuse.diary.api.Person["personList"] ...(以下省略)
所以在开发过程中,要注意编写的代码,不要造成以上错误。
在此记录下。避免以后再踩坑。
阅读全文
0 0
- Cannot call sendError() after the response has been committed 错误记录
- Cannot call sendError() after the response has been committed
- Cannot call sendError() after the response has been committed
- Cannot call sendError() after the response has been committed
- Cannot call sendError() after the response has been committed
- Cannot call sendError() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed错误
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- 【SSH异常系列】Cannot call sendError() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- struts2文件图片流输出报IllegalStateException: Cannot call sendError() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- Struts2中使用servletresponse直接输出内容到客户端出现:Cannot call sendError() after the response has been committed
- Cannot call sendRedirect() after the response has been committed
- Cannot call sendRedirect() after the response has been committed
- Cannot call sendRedirect() after the response has been committed
- Cannot call sendRedirect() after the response has been committed
- vue2.0 练习项目-外卖APP(1)
- TextureView+SurfaceTexture+OpenGL ES来播放视频(三)
- java潜在类型机制的具体实现
- 预置APK使用户可以卸载,并且恢复出厂设置时能够恢复
- PHP里一根下划线和两下划线的定义
- Cannot call sendError() after the response has been committed 错误记录
- 《用Python学习数值分析--解方程》
- 关于根据word大纲切割word 功能
- 转载设计模式
- [cnblogs镜像]页面定制CSS代码初探(六):h2、h3 标题自动生成序号 详细探索过程
- http与https的区别
- 使用idea编辑sparkSql的程序运行出现java.lang.IllegalArgumentException: java.net.URISyntaxException
- 用两个栈实现队列(队列 栈)
- 《用Python学习数值分析--解方程组》