• 使用a标签或form的submit做下载按钮,然后通过js调用其click事件去下载时经常出现的异常


    异常:

    ClientAbortException:  java.net.SocketException: Connection reset by peer: socket write error
        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:366)
        at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:432)
        at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)
        at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
        at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
        at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
        at com.joejoe.utils.IOUtils.write(IOUtils.java:62)
        at com.joejoe.utils.IOUtils.write(IOUtils.java:48)
        at com.tqsoft.wdys.other.getMegavideo.doGet(getMegavideo.java:79)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at com.joejoe.utils.web.CharSetFilter.doFilter(CharSetFilter.java:39)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.SocketException: Connection reset by peer: socket write error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(Unknown Source)
        at java.net.SocketOutputStream.write(Unknown Source)
        at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:750)
        at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:432)
        at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)
        at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:773)
        at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:118)
        at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:583)
        at org.apache.coyote.Response.doWrite(Response.java:560)
        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:361)
        ... 27 more

    1:如果使用a标签,通常会直接将超链接的href设为下载地址,然后通过js调用其click事件去实现下载,经常出现以上异常。因为当我们点击的时候本身超链接的href本身应经定向到下载地址,而后而后js有调用了a的click事件导致了又执行了一次href所以出现两次下载请求,抛出连接被重置的异常

    2:若在form里用了脚本提交,而在那个Form里面又用了submit了,这样会重复提交也会导致这种问题的。

    注意:为了避免以上两种情况出现,我们最好使用button做下载按钮

    3:可能防火墙或服务器连接数过小被使用完未关闭,也会导致该异常

  • 相关阅读:
    更新安装xcode7插件
    提交自己的插件包(package)
    数组包含字典-根据key排序
    primeng 中 pickList组件的使用
    tomcat的启动和部署
    css中如何把鼠标变成手
    angular2新建组件
    Angular2的笔记
    idea 创建springboot工程
    jfinal excel表导出
  • 原文地址:https://www.cnblogs.com/jice/p/2700193.html
Copyright © 2020-2023  润新知