我已在 weblogic 12c 服务器上部署了我的应用程序。我看到指向 out.clear();
行的响应已提交
错误。不确定为什么我只使用 weblogic 服务器会遇到这个问题 - 在 tomcat 上工作得很好。
下面是代码片段。任何帮助,将不胜感激!谢谢。
request.getRequestDispatcher(toolbarURL.toString()).include(request, customResponse);
Element toolbarCode = new Element("toolbarCode");
toolbarCode.setContent(new CDATA(customResponse.getOutput()));
root.addContent(toolbarCode);
XMLOutputter outputter = new XMLOutputter(format);
out.clear();
outputter.output(new DocType("html"), out);
outputter.output(transformer.transform(doc), out);
out.clear(); 行是抛出异常的行。
最佳答案
您没有显示 out
的声明,但我假设它是一个 JSPWriter
实例。因此,您的代码依赖于 servlet 容器的某些与实现相关的行为,即它们刷新输出的速度。一旦第一个字节被刷新(向下游发送到客户端),就可能不再调用 clear
(请参阅 documentation 。
Clear the contents of the buffer. If the buffer has been already been flushed then the clear operation shall throw an IOException to signal the fact that some data has already been irrevocably written to the client response stream.
WebLogic 12c 在刷新输出方面可能比 Tomcat 更积极。因此,清除缓冲区已经不行了。
最有可能的是,您只需删除 out.clear();
行即可修复它。
关于java - 网络逻辑- 'response already committed',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33099979/