![](/img/trans.png)
[英]Java/Spring MaxUploadSizeExceededException post parameters
[英]Getting MaxUploadSizeExceededException in my spring application
目前我正在使用Spring應用程序,它使用spring veriosn作為3.2.12.RELEASE,tomcat 7,Servlet 3.0並在我嘗試上傳大小超過2MB的文件時在tomcat控制台中獲取'MaxUploadSizeExceededException'。 它適用於小於2MB大小的文件。
我已經如下配置了CustomMultipartResolver,它依次擴展了CommonMultipartResolver: -
配置在bean實體下面。 配置maxUploadSize為200 MB
<bean id="multipartResolver" class="my.custom.multipart.resolver.CustomsMultipartResolver">
<property name="maxUploadSize" value="209715200" />
</bean>
但是我的控件不在這個類中,只是進入StandardServletMultipartResolver類的resolveMultipart方法。 對於大小超過2MB的文件,方法request.getPart()方法拋出IllegalStateException並最終獲取SizeLimitExceededException。
我也試過在我的web.xml中添加下面的代碼,但它也沒有用
<multipart-config>
<!-- 200MB max -->
<max-file-size>209715200</max-file-size>
<max-request-size>209715200</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
它的工作正常,配置相同,除非我使用Spring版本3.0.5.RELEASE,其中沒有類StandardServletMultipartResolver,控件正確進入我的CustomMultipartResolver,我可以上傳大小高達200 MB的文件。
因為這個原因,我無法繼續。
我不確定你的彈簧應用程序是如何啟動的,因為多部件解析器的名稱是錯誤的。 應該是org.springframework.web.multipart.commons.CommonsMultipartResolver
,而不是org.springframework.web.multipart.commons.CustomsMultipartResolver
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.