当前位置: 代码迷 >> 综合 >> 导出时,报 Cannot call sendError() after the response has been committed
  详细解决方案

导出时,报 Cannot call sendError() after the response has been committed

热度:28   发布时间:2023-11-26 09:12:09.0

问题描述:

        文件导出时,导出成功,但是日志打印错误日志“Cannot call sendError() after the response has been committed”,“Could not find acceptable representation”

原因:

        controller层 使用了注解 @RestController(同ResponseBody),而文件写入输出后,做了了流的关闭后,但同时也做了 return Object,导致了再次使用了response

解决方案:

        关闭流后,使用return null;

  相关解决方案