我有一个WAR应用程序,其中有两个servlet部署到Tomcat7服务器中。其中一个servlet是为了捕获RESTfull Web服务。 当我尝试上传文件时(使用多部分模式);服务器抛出以下异常:
org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (2539037) exceeds the configured maximum (2097152)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:99)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:77)
at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:76)
at org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:110)
答案 0 :(得分:3)
在src / java / resources下创建application.properties文件。然后简单地添加。
spring.http.multipart.maxFileSize = 25 MB;
答案 1 :(得分:0)
我已经解决了它只将标签定义为serlvet;属性是不必要的:
<servlet>
<servlet-name>servletname</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
<multipart-config>
</multipart-config>
</servlet>