Action请求后台出现Response already commited异常解决方法
Posted seedling
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Action请求后台出现Response already commited异常解决方法相关的知识,希望对你有一定的参考价值。
在编写导出功能使用action请求,在处理导出异常时期望跳转异常页,Controller中的方法返回类型String的url
在处理完逻辑导出文件后后台控制台出现
WARN [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] (default task-22) Handling of [org.springframework.http.converter.HttpMessageNotWritableException] resulted in Exception: java.lang.IllegalStateException: UT010019: Response already commited
and
ERROR [io.undertow.request] (default task-22) UT005023: Exception handling request to /snq-admin/data/exportDataDetail.do: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: UT010029: Stream is closed; nested exception is java.io.IOException: UT010029: Stream is closed
Caused by: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: UT010029: Stream is closed; nested exception is java.io.IOException: UT010029: Stream is closed
Caused by: java.io.IOException: UT010029: Stream is closed
在写入文件时调用requestOutputStream.write()方法已将response发出,再在Controller中return时被认为是再发送一次,因而会报错,解决这个问题只需返回null即可。
以上是关于Action请求后台出现Response already commited异常解决方法的主要内容,如果未能解决你的问题,请参考以下文章
ajax请求后台,response.sendRedirect失效,无法重定向