• Unable to parse request org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. null


    最近做一个web项目中有上传文件的功能,已经写出并在本地和部署到服务器上测试了好几个文件上传都没问题(我用的是tomcat)。部署上服务器,上传图片时有的图片大就回在tomcat日志报如下错误:

    Unable to parse request
    org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. null
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367) [commons-fileupload-1.2.1.jar:1.2.1]
    at org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest.parseRequest(JakartaMultiPartRequest.java:189) [struts2-core-2.3.15.1.jar:2.3.15.1]
    at org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest.processUpload(JakartaMultiPartRequest.java:127) [struts2-core-2.3.15.1.jar:2.3.15.1]
    at org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest.parse(JakartaMultiPartRequest.java:92) [struts2-core-2.3.15.1.jar:2.3.15.1]
    at org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper.<init>(MultiPartRequestWrapper.java:81) [struts2-core-2.3.15.1.jar:2.3.15.1]
    at org.apache.struts2.dispatcher.Dispatcher.wrapRequest(Dispatcher.java:796) [struts2-core-2.3.15.1.jar:2.3.15.1]
    at org.apache.struts2.dispatcher.ng.PrepareOperations.wrapRequest(PrepareOperations.java:134) [struts2-core-2.3.15.1.jar:2.3.15.1]
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) [struts2-core-2.3.15.1.jar:2.3.15.1]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [catalina.jar:7.0.35]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.35]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [catalina.jar:7.0.35]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [catalina.jar:7.0.35]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) [catalina.jar:7.0.35]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) [catalina.jar:7.0.35]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [catalina.jar:7.0.35]
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) [catalina.jar:7.0.35]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.35]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) [catalina.jar:7.0.35]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) [tomcat-coyote.jar:7.0.35]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) [tomcat-coyote.jar:7.0.35]
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822) [tomcat-coyote.jar:7.0.35]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_13]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_13]
    at java.lang.Thread.run(Thread.java:619) [na:1.6.0_13]
    Caused by: java.io.IOException
    at org.apache.coyote.http11.InternalAprInputBuffer.fill(InternalAprInputBuffer.java:612) [tomcat-coyote.jar:7.0.35]
    at org.apache.coyote.http11.InternalAprInputBuffer$SocketInputBuffer.doRead(InternalAprInputBuffer.java:642) [tomcat-coyote.jar:7.0.35]
    at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:124) [tomcat-coyote.jar:7.0.35]
    at org.apache.coyote.http11.InternalAprInputBuffer.doRead(InternalAprInputBuffer.java:534) [tomcat-coyote.jar:7.0.35]
    at org.apache.coyote.Request.doRead(Request.java:422) [tomcat-coyote.jar:7.0.35]
    at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:290) [catalina.jar:7.0.35]
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:431) [tomcat-coyote.jar:7.0.35]
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:315) [catalina.jar:7.0.35]
    at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:200) [catalina.jar:7.0.35]
    at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:977) [commons-fileupload-1.2.1.jar:1.2.1]
    at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:887) [commons-fileupload-1.2.1.jar:1.2.1]
    at java.io.InputStream.read(InputStream.java:85) [na:1.6.0_13]
    at org.apache.commons.fileupload.util.Streams.copy(Streams.java:94) [commons-fileupload-1.2.1.jar:1.2.1]
    at org.apache.commons.fileupload.util.Streams.copy(Streams.java:64) [commons-fileupload-1.2.1.jar:1.2.1]
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:362) [commons-fileupload-1.2.1.jar:1.2.1]
    ... 23 common frames omitted

     然后在百度和谷歌上各种搜索,大多数认为是超时而断开连接。对于解决办法一般给的不够全面,现综合给出如下:

    (1)首先,上传页面上面的 form 标签要设enctype="multipart/form-data" 参数

    (2)修改tomcat配置文件server.xml,找到类似于下面配置:

    <Connector port="8086" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />
    将上面的参数disableUploadTimeout值改为false即可。

    (3)上边(1)是我的程序中已经设置的,修改了(2)所述的配置后依然不能运行,后来又修改了tomcat配置文件server.xml中的另外一处:

    <Connector executor="tomcatThreadPool"
    port="8080" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443" /> 也在里边加入了disableUploadTimeout="false"一句。

    用了以上方法仍然不能解决,后来想到可能是服务器外加了防火墙或者限制了上传文件的大小之类的,联系网络中心进行相关设置进行设置即可。

    资料参考:

    http://www.cnblogs.com/qingxinblog/p/3437169.html

  • 相关阅读:
    梯度下降的矩阵分解公式推导
    再谈矩阵分解在推荐系统中的应用
    浅谈矩阵分解在推荐系统中的应用
    tomcat局域网内发布html
    通过JavaScript动态生成html控件
    html 复选框checkbox
    HTML <frameset>不同frame之间传值
    OpenLayers 案例一
    ubuntu java开发环境jdk安装
    如何成为Python高手
  • 原文地址:https://www.cnblogs.com/sagech/p/4538069.html
Copyright © 2020-2023  润新知