struts2檔案上傳突破2M限制

來源:互聯網
上載者:User

標籤:value   net   details   robot   ref   roi   最大   maximum   cep   

strutsuploadfileactionclassstruts設定檔[html] view plaincopyprint?    1. <action name="FileUpload" class="cn.timefly.strutsTest.FileUploadAction">      2.     <result name="success">/FileUploadResult.jsp</result>      3.     <result name="input">/FileUpload.jsp</result>      4.     <interceptor-ref name="fileUpload">      5.         <param name="maximumSize">5000000</param>      6.         <param name="allowedTypes">application/vnd.ms-powerpoint</param>      7.     </interceptor-ref>      8.     <interceptor-ref name="defaultStack" />      9. </action>   struts2檔案上傳預設的大小是2M,如果需要強制吧大小改為超過2M就會報錯如果需要上傳5M的檔案,在struts.xml設定檔中就需要加入這樣一句:[html] view plaincopyprint?    1. <constant name="struts.multipart.maxSize" value="9000000"/>  發現struts.multipart.maxSize和fileUpload攔截器的maximumSize屬性分工不同,總結如下:1.struts.multipart.maxSize掌控整個項目(一次給這個項目上傳的所有檔案)所上傳檔案的最大的Size。超過了這個size,後台報錯,程式處理不了如此大的檔案。fielderror裡面會有如下的提示:the request was rejected because its size (16272982) exceeds the configured maximum (9000000)2.fileUpload攔截器的maximumSize屬性(單個檔案的最大值)必須小於struts.multipart.maxSize的值。struts.multipart.maxSize預設2M,當maximumSize大於2M時,必須設定struts.multipart.maxSize的值大於maximumSize。3.當上傳的檔案大於struts.multipart.maxSize時,系統報錯   當上傳的檔案在struts.multipart.maxSize和maximumSize之間時,系統提示:   File too large: file "MSF的概念.ppt" "upload__5133e516_129ce85285f__7ffa_00000005.tmp" 6007104   當上傳的檔案小於maximumSize,上傳成功。來自 <http://blog.csdn.net/android_robot/article/details/6822604> 

 

struts2檔案上傳突破2M限制

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.