struts2 jpg文件上傳失敗 Content-Type not allowed

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上傳時一直顯示進度條不消失:

<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。

解決方法:

<param name="allowedTypes">
image/bmp,image/png,image/gif,image/jpeg,image/jpg,image/x-png, image/pjpeg
</param>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章