Cannot call reset() after response has been committed
程序员文章站
2022-06-26 16:59:01
下载文件报错...
前言
下载文件报错
java.lang.IllegalStateException: Cannot call reset() after response has been committed
at org.apache.catalina.connector.ResponseFacade.reset(ResponseFacade.java:347)
at ins.platfrom.services.FileService.downloadTemplate2(FileService.java:1215)
at ins.platfrom.controller.FileController.downloadTemplate(FileController.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
原因
响应需要提前清空 然后再获取输出流 顺序不能颠倒 测试中发现
// 清空response
response.reset();
fis =new FileInputStream(fileName);
out = response.getOutputStream();
本文地址:https://blog.csdn.net/HezhezhiyuLe/article/details/114268554
上一篇: 以太网新标准400Gbps
推荐阅读
-
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed解读
-
java.lang.IllegalStateException: Cannot forward after response has been committed
-
Cannot call reset() after response has been committed
-
Hibernate项目报错:Cannot call sendError() after the response has been committed
-
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed解读
-
Cannot forward after response has been committed问题分析及解决
-
Hibernate项目报错: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的解决方法