Struts2 file upload max size

2020-08-25 07:10发布

I need to upload files upto 10 MB.I used the following .In my struts.xml i configured like as follows.

<action name="doUpload" class="com.example.UploadAction">
<interceptor-ref name="fileUpload">
    <param name="maximumSize">20971520</param>
</interceptor-ref>
</action>

I did not configured any where other than this.I am getting the following error.

the request was rejected because its size (2102840) exceeds the configured maximum (2097152)

Can any one suggest me what might be the reason.Thanks in advance.

标签: struts2
3条回答
时光不老,我们不散
2楼-- · 2020-08-25 07:26

Put this in your struts.xml file

<constant name="struts.multipart.maxSize" value="30000000" />

See http://struts.apache.org/2.x/docs/file-upload.html#FileUpload-AdvancedConfiguration.

Updated link - https://cwiki.apache.org/confluence/display/WW/File+Upload

查看更多
我命由我不由天
3楼-- · 2020-08-25 07:34

Also check your container configuration. Tomcat itself, for example, has a maxPostSize parameter which, if not set defaults to 2097152 (2Mb)

查看更多
【Aperson】
4楼-- · 2020-08-25 07:43

put this code on your strtus.xml:

<constant name="struts.multipart.maxSize" value="50000000" />

where value denotes your file size limit . if you want to extend the limit you can change the value as well . hope it helps

查看更多
登录 后发表回答