【发布时间】:2015-09-04 14:30:58
【问题描述】:
在对该主题进行了一些在线研究后,我目前设法使用此代码进行处理:
@RequestMapping(value = "/report040Generated", method = RequestMethod.GET)
public String index(Model model, HttpServletResponse response, HttpServletRequest request) throws IOException {
String myString = "Hello";
response.setContentType("text/plain");
response.setHeader("Content-Disposition","attachment;filename=myFile.txt");
ServletOutputStream out = response.getOutputStream();
out.println(myString);
out.flush();
out.close();
return "index";
}
我的问题是,当我单击 JSP 按钮时,文件会被下载,但该方法不会重定向到“索引”.jsp 视图并给我一个 IllegalStateExcepton:
严重:servlet jsp 的 Servlet.service() 抛出异常 java.lang.IllegalStateException: getOutputStream() 已为此响应调用
关于可能导致此问题的任何建议?
【问题讨论】:
标签: java spring jsp spring-mvc servlets