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

遇到问题----java.lang.IllegalStateException: getOutputStream() has already been called for this response 在利用jxls导出excel时,报异常: java.lang.IllegalStateException: getOutputStream() has already been called for this response 如下所示: IllegalStateException: getOutputStream() has already been called for this r 阅读详情

在使用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了.然后我试了,对,没错了.这和上面网友的分析吻合.

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

原文地址:http://sxgxy2008.blog.163.com/blog/static/76255270201021164613946/


HTB Attacking GraphQL Skills Assessment 通过枚举应用,利用GraphQL API,发现sql注入点,然后利用找到flag。 阅读详情

相关推荐

汇川EASY系列之以太网通讯(套接字socket做主站)

本文讲解汇川Easy系列使用以太网套接字socket通讯,本例中EasyPLC做主站。文中按步进行操作。细节明确。

这是一个长期关注工控行业技术的博客,实现0-1的突破,期待您的关注和留言 2190

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

①在java代码Action中 在使用流的方法下载Excel的时候 经常会遇到如下错误: java.lang.IllegalStateException: getOutputStream() has already been called for this response 详解:在tomcat5下jsp中出现此错误一般都是在jsp中使用了输出流(如输出图片验证码,文件下载等),没有妥善处...

iteye_7017的博客 2816

红外气体检测方案解析:从NDIR原理到物联网终端设计实践

气体检测是工业安全与环境监测的核心需求,其技术原理主要基于气体分子对特定物理或化学信号的响应。非色散红外(NDIR)技术作为一种物理检测方法,通过测量气体分子对特定波长红外光的吸收来定量浓度,因其不依赖化学反应,具备寿命长、抗干扰强和响应快等优势。在工程实践中,红外气体检测方案的价值在于为物联网终端设备提供了高可靠、低功耗的感知能力,广泛应用于工业过程监控、环境空气质量监测以及智能家居安全预警等场景。本文以一套集成了Microchip MCU、Axetris红外光源和Pyreos热释电传感器的参考设计为例,

weixin_30954817的博客 393

java.lang.IllegalStateException: getReader() has already been called for this request

项目上因为有需要需要在拦截器里面获取请求体里面的数据进行数据验证,因为自己定义的controller里面对使用了@RequestBody注解,导致项目报错了报错的内容是:java.lang.IllegalStateException: getReader() has already been called for this request 查阅资料发现request里面的的getReader 和getInputStream因为是以流的方式获取的,读取一次后,后续就不能再用了,解决思路是: 第一步:定义一个过

qq_25379811的博客 4017

RK3588与FPGA高速PCIe通信:从理论带宽到实战优化的全流程解析

本文深入解析了瑞芯微RK3588与FPGA之间基于PCIe Gen2的高速通信全流程。从理论带宽计算(约1640MB/s)出发,详细拆解了硬件连接、驱动加载、DMA配置等关键步骤,并重点分享了中断优化、内存管理及高级调优等实战技巧,旨在帮助开发者从“跑通”到“跑好”,实现接近理论极限的稳定高效数据传输。

weixin_29175469的博客 332

一文解释电路中常用电子元器件应用和选型01

电容和二极管是电路中最常用的两个电子元器件,种类和系列众多,这里简单总结一下应用场景和选型方式 电容(Capacitor) 电容的种类(20种以上)和应用非常广泛,但是我经常遇到的无非就是下面这几种: 应用 1.隔直流。 2.旁路(去耦) 3.耦合 4.滤波 5.温度补偿 6.计时 7.调谐 8.整流 9.储能 种类 1. 陶瓷电容 2. 云母电容 3. 铝电解电容 4. 钽

weixin_43904073的博客 2236

简单解决java.lang.IllegalStateException: getOutputStream() has already been called f

简单解决java.lang.IllegalStateException: getOutputStream() has already been called for this respons 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputSt...

vicento4的博客 2027

维纳(Wiener)复原滤波器的三种推导形式及其在图像处理中的应用

本文深入解析了维纳(Wiener)复原滤波器的三种核心推导形式:卷积形式、矩阵向量形式和频域形式,并重点阐述了其基于线性最小均方误差(LMMSE)估计的核心思想。通过Python实战演示,展示了频域形式如何高效地在图像去模糊与噪声抑制之间取得平衡,是图像复原领域的经典且实用的工具。

net55的博客 577

报错:java.lang.IllegalStateException: getOutputStream() has already been called for this response

文章目录问题背景分析解决方案 错误信息详情: 严重: Servlet.service() for servlet [jsp] in context with path [/exportExcel] threw exception [java.lang.IllegalStateException: getOutputStream() has already been called for this ...

Charlven的博客 1727

深入解析基于Fluent的蒸发冷凝相变UDF程序及其在重力热管液体蒸发冷凝变化计算中的应用

ANSYS Fluent是一款功能强大的CFD软件,广泛应用于流体流动、传热、化学反应和多相流等领域的数值模拟。Fluent提供了丰富的物理模型和求解器,支持用户自定义函数(UDF)以扩展其功能,实现更为复杂和特定的模拟需求。UDF是用C语言编写的程序,允许用户在Fluent中自定义物理模型、边界条件、源项等,以实现特定的模拟需求。在处理复杂的相变过程、非均匀物性参数或特定的热传导机制时,UDF提供了极大的灵活性和扩展性。

qq_38334677的博客 1265

【ComfyUI 基础教程】ComfyUI 局部重绘工作流教程

本篇指南将带你了解 ComfyUI 中的局部重绘工作流,并带你完成一个局部重绘的示例,以及遮罩编辑器的使用等。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 303

java.lang.IllegalStateException: getOutputStream() has already been called for this response异常

最近在捣鼓SpringMVC的文件下载服务,使用到了ResposeEntity来处理下载服务,需要返回响应实体,而要下载的文件则需要转为对应的流然后连同响应实体一起返回出去。然后我又重新捣鼓了java平常的下载处理方式,在SpringMVC的环境下使用了原生HttpServletRespose的对象来获取输出流,最后页成功的传输了下载了文件,但是却爆出了这个异常。说我已经调用过getOutputStream()这个方法了,也就是说重复调用了。虽然无伤大雅,但是看着还是不舒服。于是便查询了一下报这个异常的原因

qq_41365804的博客 2831

二维矩形件排样算法之最低水平线算法实现

最低水平线算法的简单实现(Python) 1、二维矩形排样算法众多,最早的有BL算法、下台阶算法、最低水平线算法等,其中最低水平线算法及其优化算法应用较多,是与智能优化算法(遗传算法、模拟退火算法等)结合的最多的算法,本文利用python对最低水平线算法做了实现...

峰爸的博客 1万+

java.lang.IllegalStateException:getOutputStream() has already been called for this response的解决方法

  《轻量级J2EE企业应用实战》一书的第2章有一个使用SerlvetResponse输出图像的例子,代码如下:   BufferedImage image = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB);   Graphics g = image.getGraphics();   g.fillRect(0,0,400,4

永恒小菜的专栏 6909

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

项目踩坑之java.lang.IllegalStateException: getOutputStream() has already been called for this response

在做项目的时候,用到excel表格下载功能,虽然表格下载成功,但是控制台报如下错误 (java.lang.IllegalStateException: getOutputStream() has already been called for this response) java.lang.IllegalStateException: getOutputStream() has already been called for this response at org.apache.catalina.co

chd_sun的博客 2285

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

解决+解决思路:java.lang.IllegalStateException: getOutputStream() has already been called for this response

java.lang.IllegalStateException: getOutputStream() has already been called for this response 首先说明这个异常没有对使用功能造成影响,但是每次请求都会报出这个异常所以还是解决滴 会出现这个错误是因为我使用SpringBoot准备把kaptcha封装成工具类打算复用,当时使用到验证码的只是登陆和注册,但是使用验证码的场景还是很多,毕竟涉及到安全的问题,验证码还是很有用处的。 最先开始功能没问题感觉还是良好的,但是每.

一颗剽悍的种子的博客 8414

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

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

今天遇到java.lang.IllegalStateException: getOutputStream() has already been called for this response或者getInputStream() has already been called for this request的问题 看了很多经验都没用,也没有显式调用getwriter和getOutputStre...

familylammy的博客 8509
上一篇: Null value was assigned to a property of primitive type setter ,hibernate int型数据无法读取 hiberante读int
下一篇: 在dwr中获得request、response对象
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值