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);
Handling of [org.springframework.http.converter.HttpMessageNotWritableException] resulted in Exception
java.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"] ...(以下省略)
Cannot call sendError() after the response has been committed 错误记录
Cannot call sendError() after the response has been committed 错误记录在使用Spring MVC开发过程中遇到了一个十分迷惑的错误 Response has been committed。通过打断点,发现代码都正常运行通过,但是就是一直报这个错,于是仔细观察代码发现有段代码中对象引用形成了一个循环,如下代码: JSONObject