FileUploadBase$SizeLimitExceededException apache tomcat

后端 未结 4 1805
不知归路
不知归路 2021-02-04 04:36

Im trying to upload file from a JSP file and I get the following error in catalina.out. As specified in many blogs, I increased the the max-file-size under webapps/manager/WEB-

相关标签:
4条回答
  • 2021-02-04 05:07

    I had the same problem. I solved it by setting the parameter maxPostSize in the http server tomcat connector located in <tomcat-root-folder>/conf/server.xml as follows:

    <Connector connectionTimeout="20000" 
               port="8080" 
               protocol="HTTP/1.1" 
               redirectPort="8443" 
               maxPostSize="52428800" />
    

    Set maxPostSize to 52428800 increase the upload file size to 50 MB. By default it's set to 2 MB.

    For more explanation, read this: https://tomcat.apache.org/tomcat-7.0-doc/config/http.html

    0 讨论(0)
  • 2021-02-04 05:14

    https://maxrohde.com/2011/04/27/large-war-file-cannot-be-deployed-in-tomcat-7/

    Go to the web.xml of the manager application (for instance it could be under /tomcat7/webapps/manager/WEB-INF/web.xml. Increase the max-file-size and max-request-size:

    <multipart-config>
    <!– 50MB max –>
    <max-file-size>52428800</max-file-size>
    <max-request-size>52428800</max-request-size>
    <file-size-threshold>0</file-size-threshold>
    </multipart-config>
    
    0 讨论(0)
  • 2021-02-04 05:16

    This is configured in web.xml for the manager app.

    Ex:

      <servlet>
        <servlet-name>HTMLManager</servlet-name>
        <servlet-class>org.apache.catalina.manager.HTMLManagerServlet</servlet-class>
        <init-param>
          <param-name>debug</param-name>
          <param-value>2</param-value>
        </init-param>
        <multipart-config>
          <!-- 50MB max -->
          <max-file-size>52428800</max-file-size>
          <max-request-size>52428800</max-request-size>
          <file-size-threshold>0</file-size-threshold>
        </multipart-config>
      </servlet>
    

    https://github.com/apache/tomcat/blob/7.0.x/webapps/manager/WEB-INF/web.xml#L56-L57

    The manager app uses the Servlet 3.0 API. If you're using commons file upload directly, it's up to you and you need to configure this manually.

    0 讨论(0)
  • 2021-02-04 05:21

    you can use in Servlet like bellow

        @WebServlet(name = "RemittanceDocApi", urlPatterns = {"/RemittanceDocApi"})
        @MultipartConfig(fileSizeThreshold = 1024 * 1024 * 2, // 2MB
        maxFileSize = 1024 * 1024 * 10, // 10MB
        maxRequestSize = 1024 * 1024 * 50)   // 50MB
        public class RemittanceDocApi extends HttpServlet {
    
        }
    
    0 讨论(0)
提交回复
热议问题