`

struts2 jpg文件上传失败 Content-Type not allowed 解决方案

 
阅读更多

org.apache.struts2.interceptor.FileUploadInterceptor - Content-Type not allowed: upload "upload__75549ca5_1239ddc5ce6__8000_00000161.tmp" image/pjpeg

原有配置:用ext+struts2上传时一直显示进度条不消失:

Java代码
  1. <action name="xxxAction"  
  2.     class="com.web.action.xxxAction">   
  3.     <interceptor-ref name="fileUpload">   
  4.      <param name="allowedTypes">   
  5.      image/bmp,image/png,image/gif,image/jpeg,image/jpg   
  6.      </param>   
  7.      <param name="maximumSize">200000000000</param>   
  8.     </interceptor-ref>   
  9.     <interceptor-ref name="defaultStack" />   
  10.     <result>/welcome.jsp</result>   
  11. </action>  
<action name="xxxAction"
    class="com.web.action.xxxAction">
    <interceptor-ref name="fileUpload">
     <param name="allowedTypes">
     image/bmp,image/png,image/gif,image/jpeg,image/jpg
     </param>
     <param name="maximumSize">200000000000</param>
    </interceptor-ref>
    <interceptor-ref name="defaultStack" />
    <result>/welcome.jsp</result>
</action>



原因:ie会把 jpg、jpeg翻译成image/pjpeg,png翻译成image/x-png 。而火狐则很标准:jpg、jpeg翻译成image/jpeg,png翻译成image/png。

解决方法:

Java代码
  1. <param name="allowedTypes">   
  2.       image/bmp,image/png,image/gif,image/jpeg,image/jpg,image/x-png, image/pjpeg   
  3. </param>   
  4.    
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics