首页 > 其他分享 >struts2 jpg文件上传失败 Content-Type not allowed 解决方案

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

时间:2023-05-10 15:32:40浏览次数:41  
标签:image jpeg Content 翻译成 jpg Type png pjpeg

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



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


Java代码


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

标签:image,jpeg,Content,翻译成,jpg,Type,png,pjpeg
From: https://blog.51cto.com/u_873039/6262318

相关文章

  • python 报错:TypeError: only integer scalar arrays can be converted to a scalar in
    defconvolution(initial_img,kernal):img=np.zeros((initial_img.shape[0],initial_img.shape[1])).astype(np.uint8)forxinrange(1,initial_img.shape[0]-1):foryinrange(1,initial_img.shape[1]-1):temp=np.zeros([3,3......
  • requests标头在json序列化时报错TypeError: Object of type CaseInsensitiveDict is n
    requests的作者似乎为了解决header里大小写兼容的问题,而创建了大小写不敏感的数据结构CaseInsensitiveDict,具体分析可以参见:详解Requests中的数据结构CaseInsensitiveDict。requests返回的response_header即是一个CaseInsensitiveDict类型,而且我们知道response_header里通常并非......
  • Typedef
     typedef是什么为什么要typedef开始解答:Typedef是用来给数据类型取别名,因此必须先有原始数据类型,格式如下:<typedef><已有类型名><新类型名>Typedef通常用在两个方面方便移植:在不同的平台下,基础数据类型占用空间可能不太一样,通过typedef已有数据类型,可以很方便的进......
  • 用C#将多个jpg合成一个pdf
    nuget安装iTextSharp:staticvoidMergePDF(stringpicPath,stringpdfPath){string[]picFileNames=Directory.GetFiles(picPath,"*");List<string>fileNames=picFileNames.ToList();fileNames.Sort((l,......
  • 设置键盘只能输入数字( phoneNumTextField.keyboardType = UIKeyboardTypeNumberPad;)
    //手机号码textFieldphoneNumTextField=[[UITextFieldalloc]initWithFrame:CGRectMake(0,0,[[UIScreenmainScreen]bounds].size.width,40)];UIView*phoneImage=[[UIViewalloc]initWithFrame:CGRectMake(0,0,40,40)];phoneImage.backgroundColor=[U......
  • define和typedef的区别
    #defineLGlongtypedeflongLG; 1.define是宏定义,不是语句,末尾不加分号,而typedef要加;2.#define [sign] [content],define宏定义是先定义符号,然后后面跟上符号要替换的内容,   typedef [type] [sign],typedef是将某种已有的类型用自定义符号代替,因此自定义符号......
  • 【Oracle】使用xmlagg(xmlparse(content()).getclobval()拼接信息
    使用xmlagg(xmlparse(content()).getclobval()拼接信息简单来说格式如下xmlagg(xmlparse(content(内容||分割符)).getclobval()内容就是使用显示的数据部分,分隔符不同效果不同,分隔符可以使用chr()函数无分隔符xmlagg(xmlparse(content('这是一个字段:'||v.supercode||'、......
  • Git--no matching host key type found. Their offer: ssh-rsa
     解决方法:在用户目录下的.ssh文件夹下新建一个config文件Host*HostKeyAlgorithms+ssh-rsaPubKeyAcceptedKeyTypes +ssh-rsa......
  • 【Issues】axios如何获取responseType为blob的请求的错误信息
    问题背景axios请求下载文件时会设置responseType:'blob’来处理,此时如果响应数据错误,则无法下载文件且同时没有把相关的错误信息提示处理。因为返回的是Blob对象,无法获取到普通对象中的错误信息。例如:{"code":450002,"data":null,"msg":"下载出错"}这就需要在下载文件时做......
  • Mixed Content: xxx This request has been blocked; the content must be served ove
    1.情景展示这是教师资格证,准考证的下载界面。当我们去点击“下载准考证”的时候,你将发现点击该按钮并没有反应。按F12,打开开发者工具。该网站,会自动进入断点调试模式,目的是为了:禁止前端开发者查看网页代码之类的吧。我们要想看看,为什么无法下载准考证,就不能够被它拦住。......