前端套了ruoyi,使用com.jfinal.cos 2020.4正常,升级为2022.2。会在cotroller使用getFile()时,调用Cotroller.class 的 new MultipartRequest强制转换报错:
Caused by: java.lang.NoSuchMethodError: com.oreilly.servlet.MultipartRequest.<init>(Ljavax/servlet/http/HttpServletRequest;Ljava/lang/String;ILjava/lang/String;Lcom/oreilly/servlet/multipart/FileRenamePolicy;)V
at com.jfinal.upload.MultipartRequest.wrapMultipartRequest(MultipartRequest.java:107)
at com.jfinal.upload.MultipartRequest.<init>(MultipartRequest.java:58)
at com.jfinal.core.Controller.getFiles(Controller.java:846)
at com.jfinal.core.Controller.getFile(Controller.java:851)
自定义UploadController.java
uploadFile = getFile("file", UploadService.uploadTempPath, UploadService.imageMaxSize);
Cotroller.class:
List<UploadFile> () { (!(.MultipartRequest)) { .= MultipartRequest(.)} ((MultipartRequest).).getFiles()}
前端js
(fileobj) { data = ()data.(file)data.()data.().({ : : + : data: : : : : (result) { (result.== .) { (obj).(result.result.)} { ..(result.)} }: (error) { ..()} })}
项目:JFinal
// 上传文件
function sendFile(file, obj) {
var data = new FormData();
data.append("file", file);
data.append("uploadType", 'article');
data.append("action", "uploadimage");
$.ajax({
type: "POST",
url: ctx + "common/upload/uploadImage",//ctx + "/tool/upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
$(obj).summernote('editor.insertImage', result.url, result.fileName);
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertWarning("图片上传失败。");
}
});
}