文件大小adBase $SizeLimitExceedException Apache tomcat

vecaoik1  于 8个月前  发布在  Apache
关注(0)|答案(6)|浏览(71)

我试图从JSP文件上传文件,我在catalina. out中得到以下错误。正如许多博客中所指出的那样,我增加了webapps/manager/WEB-INF/web.xml下的最大文件大小,但我仍然有同样的问题.我应该在哪里增加它来解决这个错误?

<multipart-config>
      <!-- 50MB max -->
      <max-file-size>5242880000000</max-file-size>
      <max-request-size>5242880000000</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (341297) exceeds the configured maximum (51200)

字符串

gojuced7

gojuced71#

我遇到了同样的问题。我通过在位于<tomcat-root-folder>/conf/server.xml的http服务器tomcat连接器中设置参数maxPostSize来解决它,如下所示:

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

字符串
maxPostSize设置为52428800将上传文件大小增加到50 MB。默认情况下,它设置为2 MB
有关更多解释,请阅读:https://tomcat.apache.org/tomcat-7.0-doc/config/http.html

smtd7mpg

smtd7mpg2#

https://maxrohde.com/2011/04/27/large-war-file-cannot-be-deployed-in-tomcat-7/
转到管理器应用程序的web.xml(例如,它可以在/tomcat 7/webapps/manager/WEB-INF/web.xml下。增加max-file-size和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>

字符串

xmq68pz9

xmq68pz93#

这在web.xml中为管理器应用程序配置。
例如:

<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
管理器应用程序使用Servlet 3.0 API。如果您直接使用commons文件上传,则由您决定,您需要手动配置。

liwlm1x9

liwlm1x94#

如果您使用的是Spring MultipartResolver,请找到bean并更改它的maxRightAdSize属性。

`<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
   <property name="maxUploadSize" value="52428800" />
 </bean>`

字符串
给定的代码将上传文件大小设置为50 MB

u3r8eeie

u3r8eeie5#

你可以在Servlet中使用,如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 {

    }

字符串

gzjq41n4

gzjq41n46#

如果你从spring微服务中获得hit limit(内部是tomcat,但没有web.xml):
超过最大上载大小;嵌套异常为java.lang.IllegalStateException:org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException:请求被拒绝,因为其大小(26025118)超过配置的最大值(25165824)
申请微服务启动参数(每个文件500 MB上传限制):

-spring.servlet.multipart.max-file-size=500MB
  -spring.servlet.multipart.max-request-size=500MB

字符串

相关问题