`
wdmd5211314
  • 浏览: 2236 次
  • 性别: Icon_minigender_1
  • 来自: 哈尔滨
最近访客 更多访客>>
社区版块
存档分类

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

阅读更多

【转】http://sxgxy2008.blog.163.com/blog/static/76255270201021164613946/

在使用struts2 +hibernate+spring 框架的项目中,用到下载,在下载时后台爆出下列异常:

严重: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:604)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:112)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:178)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77)
at org.apache.jsp.success_jsp._jspService(success_jsp.java:132)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
at org.apache.struts.chain.commands.servlet.PerformForward.handleAsInclude(PerformForward.java:127)
at org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:78)
at org.apache.struts.chain.commands.AbstractPerformForward.execute(AbstractPerformForward.java:51)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:48)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:280)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)

网上查了一下资料,情况如下,

这个问题困扰了半天,在网上查阅了大量资料,基本上就是出自一两家之口.感觉说得也有道理response.getWriter()和response.getOutputStream()相冲突造成的.但我没在jsp用response,

response这个对象是Servlet自己管理的,之所以出现上面的错误:
1.网上都说跟Output之类其他的输出流相互排斥了。
2.也可能是多次调用那个Struts里面定义的方法。
3.最后查出原因:Struts方法之间调用引起的。
因为:每个方法都返回的是一个ActionForward对象,而response是ActionForward对象参数,所以就会使response冲突!
分析得很有道理然后又在javaeye上看到一个网友说return null就ok了.然后我试了,对,没错了.这和上面网友的分析吻合.

 

这个问题算告一段落了.感谢网友提供的帮助支持哈!

分享到:
评论
1 楼 wdmd5211314 2010-08-28  
确实好使

相关推荐

    java.lang.IllegalStateException: getOutputStream() has already解决办法

    纠结了半天的 java.lang.IllegalStateException: getOutputStream() has already。这个问题困扰了半天,在网上查阅了大量资料 出这个错误一般就是下面2个.....

    java.lang.IllegalStateException: Cannot call sendError() after the response has

    在Java的Web开发中,`java.lang.IllegalStateException: Cannot call sendError() after the response has been committed` 是一个常见的错误,通常发生在尝试在HTTP响应已经发送到客户端之后调用`sendError()`方法...

    java.lang.IllegalStateException: OutputStream already obtain

    标题 "java.lang.IllegalStateException: OutputStream already obtain" 涉及到的是Java编程中的一个常见错误,特别是当处理I/O流时。这个异常通常在尝试获取已经存在的OutputStream实例时抛出,表明该输出流已经被...

    关于IllegalStateException: The specified child already has a parent.

    IllegalStateException: The specified child already has a parent.我的博客中有文章讲解

    Android异常 java.lang.IllegalStateException解决方法

    1. java.lang.IllegalStateException: No wrapped connection. 2.java.lang.IllegalStateException: Adapter is detached. 原因: 1.单线程一次执行一个请求可以正常执行,如果使用多线程,同时执行多个请求时就会...

    ListView后台更新报错:java.lang.IllegalStateException

    java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but...

    spring入门好教程

    《Spring框架:开启Java开发新纪元》 Spring框架,由Rod Johnson创立并由Interface21公司推广,自诞生以来,它就致力于简化Java企业级应用(J2EE)的开发,提供了一种非侵入式的解决方案,极大地提高了开发效率。它...

    Failed to convert value of type ‘java.lang.String’ to required type ‘java.util.Date’; nested except

    Type 异常报告 消息 Failed to convert ... nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.util.Date': no matching editors or co

    powerbuilder

    ### PowerBuilder 中从 Excel 导入数据到 DataWindow 的实现方法 #### 标题解析: 在 PowerBuilder 开发环境中,经常需要将外部数据源(如 Excel 文件)中的数据导入到程序内部的数据展示组件(DataWindow)中进行...

    asm5.0.jar

    2013-08-12 14:33:37.672:... Add CGLIB to your classpath.:java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor as super class

    xfire访问webservice客户端用到的jar包

    在Java开发中,Web服务(Web Service)是一种标准的接口,允许不同系统之间进行通信,而XFire是早年流行的一款用于构建和消费Web服务的开源框架。它使用SOAP(简单对象访问协议)和XML(可扩展标记语言)作为基础,...

    Jnative1.4_java调用动态库所需jar

    Java是一种高级编程语言,通常用于开发跨平台的应用程序。然而,有时我们可能需要在Java程序中调用操作系统底层的动态链接库(DLLs on Windows,SOs on Linux,dylibs on macOS),以便利用C、C++等语言编写的高性能...

    action-buffer:提供了在处理后台任务时避免片段过渡期间出现 IllegalStateException 的示例

    这个存储库提供了一种在处理片段传输和后台任务时避免“java.lang.IllegalStateException:Can not perform this action after onSaveInstanceState”的方法。 您可以在的非常权威的阅读有关该问题和可能的解决方案...

    nexus-3.70.1-02-java17-unix.tar.gz

    java.lang.IllegalStateException: The maximum Java version for OrientDb is Java 11. Please check current Java version meets this requirement. 参见: ...

    借助Ehcache缓存框架实现对页面的缓存Demo

    信息: Illegal access: this web application instance has been stopped already. Could not load net.sf.ehcache.store.disk.DiskStore$KeySet. The eventual following stack trace is caused by an error thrown...

    The full error is: java.lang.IllegalState

    标题中的"The full error is: java.lang.IllegalStateException"是一个典型的Java编程错误,通常表示在不合法或不适当的状态下调用了某个方法。这个错误通常暗示程序试图执行一个不能在这个特定时刻执行的操作。让...

    oop object , for apple ios developer

    ### 面向对象编程与Objective-C:苹果iOS开发者指南 #### 一、概述 面向对象编程(Object-Oriented Programming, OOP)是一种广泛应用于软件开发中的编程范式,它将程序设计围绕“对象”进行组织。...

    For gd&t not affected - when to revise dwg guidelines 3-21-02.ppt

    标题提及的“For gd&t not affected - when to revise dwg guidelines 3-21-02.ppt”指的是在GD&T未受工程变更影响时,如何判断是否需要更新图纸的指导原则。描述进一步强调了当GD&T不受工程变更影响时,确定图纸...

Global site tag (gtag.js) - Google Analytics