gpt4 book ai didi

java.io.IOException : Posted content type isn't multipart/form-data 异常

转载 作者:行者123 更新时间:2023-11-29 08:02:46 25 4
gpt4 key购买 nike

我已经编写了一个 jsp 页面,用于使用 com.oreilly.servlet.multipart.MultipartParser 使用 POST 方法上传图像,实际上文件已成功上传并且发布值也正确但它抛出异常

java.io.IOException: Posted content type isn't multipart/form-data 
MultipartParser mp = null;
try{
mp = new MultipartParser(request, 1*1024*1024); // 10MB
}
catch(Exception e){
out.println("Exception1:"+e);
}
while ((part = mp.readNextPart()) != null) {
name = part.getName();
if (part.isParam()) {
ParamPart paramPart = (ParamPart) part;
value = paramPart.getStringValue();
if(name.equals("companyname") && value != null){

}

if(name.equals("version") && value != null && name != null){

}

}
else if (part.isFile()) {
String getimagelogovalue="";
FilePart filePart = (FilePart) part;
String fileName = filePart.getFileName();
if (fileName != null) {

}
else {}
out.flush();
}
}

最佳答案

你有:

mp = new MultipartParser(request, 1*1024*1024); // 10MB

但根据我的计算,实际上只有 1Mb。您尝试上传的图像是否真的太大了?尝试使用较小的图像,修复您的评论或修复您的代码。

关于java.io.IOException : Posted content type isn't multipart/form-data 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13394784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com