struts2 文件上传 限制大小,格式
<constant name="struts.multipart.maxSize" value="2097152"></constant>
文件大小限制为2M
文件过滤器,允许text和png上传 ,配置一个过滤器,所有的默认过滤器都会失效,所以要重新配置
<interceptor-ref name="fileUpload">
<param name="allowedTypes">text/plain,image/png</param>
</interceptor-ref>
<!-- 允许后缀名为png,bmp,jpg,doc,xls的文件上传 -->
<param name="allowedExtensions">
png,bmp,jpg,doc,xls
</param>
<interceptor-ref name="defaultStack"/>
input 为 过滤器拦截时产生的返回值 ,默认
<result name="input">/index.jsp</result>
注意:action类要继承 ActionSupport