java.lang.IllegalStateException: Cannot call sendError() after the response has been committe【SSH】

问题描述:

严重: Servlet.service() for servlet [default] in context with path [/AttendanceManager] threw exception
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed

严重: Servlet.service() for servlet [default] in context with path [/AttendanceManager] threw exception
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
	at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:456)
	at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:753)
	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
	at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)

然后发现在Chrome上, 出现一个error

net::ERR_INCOMPLETE_CHUNKED_ENCODING

java.lang.IllegalStateException: Cannot call sendError() after the response has been committe【SSH】_第1张图片

于是网上各种搜解决办法,有大佬说是Tomcat的header的缓存区大小不够,于是找到了在Tomcat的conf中把server.xml中增加maxHttpHeaderSize的字段或者是把maxHttpHeaderSize的数值调大了,都没有解决这个异常;

终于,今天发现了问题所在,看了另一个大佬的问题描述,大佬是这样分析的;

问题分析:

从提示错误的字面意思判断“Cannotcall sendError() after the response has been committed”,“当response被提交后不能调用sendError()”。

出现这个错误,应该是多次response导致的,可以这么理解,http server发送response后就关闭了socket,这个时候再次发送response给http client就会出现这个问题。

【原文链接:https://blog.csdn.net/u012377333/article/details/72263686

于是我就去找;发现了CheckImg.java中,原来多次response提交;

如下是我的解决办法:

java.lang.IllegalStateException: Cannot call sendError() after the response has been committe【SSH】_第2张图片

小伙伴们,你们学会了吗?如果觉得对你们有所帮助,记得给怂怂右上角点个赞哦!你们的点赞就是给我最大的鼓励!加油!

你可能感兴趣的:(#,SSH)