简体   繁体   English

Spring MVC: java.lang.IllegalStateException: getOutputStream() 已经被这个响应调用

[英]Spring MVC : java.lang.IllegalStateException: getOutputStream() has already been called for this response

java.lang.IllegalStateException: getOutputStream() has already been called for this response java.lang.IllegalStateException: 已经为此响应调用了 getOutputStream()

I am getting above error at return statement.我在返回语句中遇到以上错误。 In below two statements in method either one statement is working fine but not both.在方法的下面两个语句中,其中一个语句工作正常,但不能同时工作。

public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
           ExcelUtils.downloadExcel(response.getOutputStream(), getExportData(command.getFile(), errors));
           return this.showForm(request, response, errors);
}

Here I am trying to download excel file and return to page to display message.我在这里尝试下载 excel 文件并返回页面以显示消息。 Can we can't call response.getOutputStream() and this.showForm(request, response, errors) or return new ModelAndView("redirect:/importPage.do") or return new ModelAndView("forward:/importPage.do") in single flow?我们不能调用 response.getOutputStream() 和 this.showForm(request, response, errors) 或 return new ModelAndView("redirect:/importPage.do") 或 return new ModelAndView("forward:/importPage.do")在单流?

If you have this problem only the second time you export, try adding:如果您只是在第二次导出时遇到此问题,请尝试添加:

response.getOutputStream().flush();
response.getOutputStream().close();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.IllegalStateException:已经为此响应调用了 getOutputStream() - java.lang.IllegalStateException: getOutputStream() has already been called for this response java.lang.IllegalStateException:已为此响应调用了getOutputStream() - java.lang.IllegalStateException: getOutputStream() has already been called for this response Spring Boot Web应用程序:引发java.lang.IllegalStateException:此响应已调用getOutputStream() - Spring Boot Web Application: throwing java.lang.IllegalStateException: getOutputStream() has already been called for this response Spring:java.lang.IllegalStateException:已经为此响应调用了getOutputStream() - Spring: java.lang.IllegalStateException: getOutputStream() has already been called for this response 原因:java.lang.IllegalStateException:此响应已经调用了getOutputStream()。 - Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response org.apache.jasper.JasperException:java.lang.IllegalStateException:此响应已调用getOutputStream() - org.apache.jasper.JasperException: java.lang.IllegalStateException: getOutputStream() has already been called for this response REST-java.lang.IllegalStateException:此响应已调用getOutputStream() - REST - java.lang.IllegalStateException: getOutputStream() has already been called for this response java.lang.IllegalStateException:此响应已经被调用getOutputStream()-SpringBoot - java.lang.IllegalStateException: getOutputStream() has already been called for this response - SpringBoot 我得到一个异常:java.lang.IllegalStateException:已经为此响应调用了getOutputStream() - I am getting an exception: java.lang.IllegalStateException: getOutputStream() has already been called for this response 我正在获取java.lang.IllegalStateException:此响应已调用getOutputStream()异常 - I m getting java.lang.IllegalStateException: getOutputStream() has already been called for this response Exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM