struts2中怪异问题FileUploadInterceptor拦截器失效。
有个问题相当迷茫,在上传多文件的时候配置了限制文件类型和大小,,然后传个错误类型文件,后台能够截获文件类型不匹配,且大小过大,可是奇怪的是,居然执行结果文件还是上传上去了。(同样的配置方式上传单个文件能够截获类型,大小错误,且能正确返回到input指定页面,唯独这在执行多文件上传时候后台截获了可是返回了上传成功页面,且文件成功上传上去了)
下面是后台信息:(中文处为显示调试打印信息)
严重: File too large: filedata "upload_43039390_11a342c434b__8000_00000000.tmp" 3894389
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [struts]
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Content-Type not allowed: filedata "upload_43039390_11a342c434b__8000_00000001.tmp" application/msword
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [struts]
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Content-Type not allowed: filedata "upload_43039390_11a342c434b__8000_00000002.tmp" application/octet-stream
file is :/tmp/upload_43039390_11a342c434b__8000_00000000.tmp fileName:opera.exe fileType:application/octet-stream
file is :/tmp/upload_43039390_11a342c434b__8000_00000001.tmp fileName:application base.doc fileType:application/msword
file is :/tmp/upload_43039390_11a342c434b__8000_00000002.tmp fileName:11.rar fileType:application/octet-stream
------------执行文件上传中--------
文件上传路径: :D:/Java/apache-tomcat-5.5.20/webapps/strutsstudy/WEB-INF/webfile/opera.exe
接收到的文件file is :0--/tmp/upload_43039390_11a342c434b__8000_00000000.tmp
开始执行上传第 0个文件
第 0个文件上传结束
------------执行文件上传中--------
文件上传路径: :D:/Java/apache-tomcat-5.5.20/webapps/strutsstudy/WEB-INF/webfile/application base.doc
接收到的文件file is :1--/tmp/upload_43039390_11a342c434b__8000_00000001.tmp
开始执行上传第 1个文件
第 1个文件上传结束
------------执行文件上传中--------
文件上传路径: :D:/Java/apache-tomcat-5.5.20/webapps/strutsstudy/WEB-INF/webfile/11.rar
接收到的文件file is :2--/tmp/upload_43039390_11a342c434b__8000_00000002.tmp
开始执行上传第 2个文件
第 2个文件上传结束
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [org.apache.catalina.jsp_file]
2008-5-29 18:14:56 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
-------------------------------------------------------
我的action的配置:
<action name="upmany" class="com.study.web.action.UploadManyFilesAction">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">text/plain </param>
<param name="maximumSize">2731088 </param>
</interceptor-ref>
<interceptor-ref name="defaultStack"> </interceptor-ref>
<result name="suc">/WEB-INF/jsp/test/suc.jsp </result>
<result name="input">/WEB-INF/jsp/test/htmlUpload.jsp </result>
<result name="err">/WEB-INF/jsp/test/err.jsp </result>
</action>
--------------
问题解决:
原因忘了继承ActionSupport类
下面是后台信息:(中文处为显示调试打印信息)
严重: File too large: filedata "upload_43039390_11a342c434b__8000_00000000.tmp" 3894389
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [struts]
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Content-Type not allowed: filedata "upload_43039390_11a342c434b__8000_00000001.tmp" application/msword
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [struts]
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Content-Type not allowed: filedata "upload_43039390_11a342c434b__8000_00000002.tmp" application/octet-stream
file is :/tmp/upload_43039390_11a342c434b__8000_00000000.tmp fileName:opera.exe fileType:application/octet-stream
file is :/tmp/upload_43039390_11a342c434b__8000_00000001.tmp fileName:application base.doc fileType:application/msword
file is :/tmp/upload_43039390_11a342c434b__8000_00000002.tmp fileName:11.rar fileType:application/octet-stream
------------执行文件上传中--------
文件上传路径: :D:/Java/apache-tomcat-5.5.20/webapps/strutsstudy/WEB-INF/webfile/opera.exe
接收到的文件file is :0--/tmp/upload_43039390_11a342c434b__8000_00000000.tmp
开始执行上传第 0个文件
第 0个文件上传结束
------------执行文件上传中--------
文件上传路径: :D:/Java/apache-tomcat-5.5.20/webapps/strutsstudy/WEB-INF/webfile/application base.doc
接收到的文件file is :1--/tmp/upload_43039390_11a342c434b__8000_00000001.tmp
开始执行上传第 1个文件
第 1个文件上传结束
------------执行文件上传中--------
文件上传路径: :D:/Java/apache-tomcat-5.5.20/webapps/strutsstudy/WEB-INF/webfile/11.rar
接收到的文件file is :2--/tmp/upload_43039390_11a342c434b__8000_00000002.tmp
开始执行上传第 2个文件
第 2个文件上传结束
2008-5-29 18:14:55 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [org.apache.catalina.jsp_file]
2008-5-29 18:14:56 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
-------------------------------------------------------
我的action的配置:
<action name="upmany" class="com.study.web.action.UploadManyFilesAction">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">text/plain </param>
<param name="maximumSize">2731088 </param>
</interceptor-ref>
<interceptor-ref name="defaultStack"> </interceptor-ref>
<result name="suc">/WEB-INF/jsp/test/suc.jsp </result>
<result name="input">/WEB-INF/jsp/test/htmlUpload.jsp </result>
<result name="err">/WEB-INF/jsp/test/err.jsp </result>
</action>
--------------
问题解决:
原因忘了继承ActionSupport类