Tag: outputstream illegalstateexception

Spring:已经为此响应调用了getOutputStream()

我知道还有很多其他post处理同样的错误,但所有这些都是关于JSP / GSP页面或者出于任何其他原因在我的情况下不是很有用。 我正在使用Spring MVC和Thymeleaf。 以下function用于下载文件。 @RequestMapping(value = “/test/download/*”, method = RequestMethod.GET) public String getFile(HttpServletResponse response) { ServletOutputStream stream = null; try { stream = response.getOutputStream(); MultipartFile f = test.getFile(); InputStream is = f.getInputStream(); IOUtils.copy(is, stream); response.flushBuffer(); stream.flush(); stream.close(); } catch(Exception ex) { } return “test”; } 它确实有效,所以它不是太大的问题,但在控制台中,我总是收到以下错误: 2014-01-10T09:28:09.053+0100 SEVERE Servlet.service() for servlet [dispatcherServlet] in […]

java.lang.IllegalStateException:已经使用输出流

当用户点击按钮时,客户端浏览器上的windchill GUI应该在他的系统上下载特定的pdf文件。我已经通过使用以下代码实现了这一点。 0) { out2.write(b, 0, len); out.println(“Your Pdf Document Is Generated Please close it”); } filein.close(); out2.flush(); out2.close(); } catch(Exception e) { out.println(e); } }else{ String error =”File Not Found Or File Has Bean Deleted Already”; request.setAttribute(“error”, error); RequestDispatcher s = request.getRequestDispatcher(“NoFile.jsp”); s.forward(request, response); } %> 此代码工作正常,文件正在下载,但之后它会引发exception。以下是我的方法服务器日志 ERROR : org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Windchill].[jsp] – Servlet.service() for servlet […]