【发布时间】:2015-11-09 15:11:30
【问题描述】:
我有一个表单,用户只能上传 pdf 文件。我使用以下 struts 操作来限制大小和文件类型,但只有大小限制有效。关于我所缺少的任何想法?谢谢!
<action name="commentAction" class = "gov.mo.dnr.rat.controller.comment.CommentAction">
<interceptor-ref name="validUserStack">
<param name="fileUpload.maximumSize">5242880</param>
<param name="allowedTypes">application/pdf</param>
</interceptor-ref>
<result name="success" type="tiles">comment</result>
<result name="input" type="tiles">comment</result>
</action>
【问题讨论】:
-
作为maximumSize,allowedTypes是fileUpload拦截器的一个参数,如果在栈内使用则需要加前缀十 def:
<param name="fileUpload.allowedTypes">application/pdf</param>,如described here。最后只是一个错字,所以不需要回答
标签: java struts2 struts2-interceptors