如何在struts 2中指定上传文件大小限制? [英] how to specify upload file size limit in struts 2?

查看:30
本文介绍了如何在struts 2中指定上传文件大小限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将默认文件上传大小从 2MB 增加到 10MB.并在我的 struts.xml 文件中进行了一些更改并添加了

I am trying to increase the default file upload size from from 2MB to 10 MB. and made some change in my struts.xml file.and added

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

<interceptor-ref name="fileUpload">
        <param name="maximumSize">500000</param>
</interceptor-ref> 

到当前配置.但是属性对象值为空!!并且上传不成功.有人建议解决这个问题.

to current configuration. but the the property object value is null!! and the upload is not successful. some one suggest any solution for this problem.

推荐答案

您是否检查过您的应用服务器?例如,Tomcat 有自己的文件上传限制(默认为 2MB).

Have you checked your application server? For example, Tomcat has it's own file upload limit (by default 2MB).

在 Tomcat 的 conf 文件夹中的 server.xml 文件中,您必须添加具有最大文件大小(以字节为单位)的 maxPostSize 属性.对于 10MB,这将类似于:

In the server.xml file in Tomcat's conf folder you would have to add the maxPostSize attribute with the maximum file size (in bytes). For 10MB, that would be something like:

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

我不太了解其他应用服务器的配置,但应该不会有太大不同.

I don't really know about the configuration for other app servers, but shouldn't be much different.

这篇关于如何在struts 2中指定上传文件大小限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆