`
taote
  • 浏览: 33892 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

java.lang.IllegalStateException: getOutputStream() has already been called for t

阅读更多
后台报错信息:
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at org.springframework.web.servlet.view.velocity.VelocityView.mergeTemplate(VelocityView.java:517)
at org.springframework.web.servlet.view.velocity.VelocityView.doRender(VelocityView.java:462)
at org.springframework.web.servlet.view.velocity.VelocityView.renderMergedTemplateModel(VelocityView.java:291)
at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.nankang.cati.session.LoginFilter.doFilter(LoginFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.asiainfo.portal.framework.external.PortalFirstFilter.doFilter(PortalFirstFilter.java:86)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
2013-02-20 13:27:38,421 ERROR [PortalFirstFilter] init:Request processing failed; nested exception is java.lang.IllegalStateException: getOutputStream() has already been called for this response
上面的error是在我导出列表至excel过程产生的,

根据这个信息:java.lang.IllegalStateException: getOutputStream() has already been called for this response
网上大家的一致论调为:给出了相应的解决方法,在使用完输

出流以后使用
out.clear();
out = pageContext.pushBody();

但是我是在servlet中遇到的异常,这是jsp中遇到该异常的解决方法(网上说的)
response这个对象是Servlet自己管理的,之所以出现上面的错误:
1.网上都说跟Output之类其他的输出流相互排斥了。
2.也可能是多次调用那个Struts里面定义的方法。
3.最后查出原因:Struts方法之间调用引起的。
因为:每个方法都返回的是一个ActionForward对象,而response是ActionForward对象参数,所以就会使response冲突!
分析得很有道理然后又在javaeye上看到一个网友说return null就ok了.然后我试了,对,没错了.这和上面网友的分析吻合.
特此记录
分享到:
评论
1 楼 seraphim0930 2014-04-09  
说的有道理,我就碰到了同样的问题,解决啦,大神膜拜下!

相关推荐

Global site tag (gtag.js) - Google Analytics