前端代码如下
var uploader =WebUploader.create({
swf: '../gistech/lib/fileUpload/Uploader.swf',
server: 'CommonController/fileUpLoad',
pick: {
id:"#picker",
innerHTML :"选择文件",
multiple:true
},
resize: false,
accept:{
// extensions: 'jpg,jpeg,bmp,png,pdf,PDF',
}
});
uploader.on('uploadBeforeSend',function(block,data){
/*debugger
var file = block.file;
var fileName=encodeURIComponent(file.name);
var downFlag=file.downFlag;
data.downFlag=downFlag;
data.fileName=fileName;*/
var file = block.file;
var obj=new Object();
obj.fileName =file.name;
obj.fileSize =file.size;
obj.fileType =file.type;
obj.fileFrom =that.fileFrom;
obj.objectid =that.objectid;
uploader.options.formData =obj;
console.log( uploader.options.formData)
}),
后台代码
@At("/fileUpLoad")
@GET
@POST
@Ok("json")
@AdaptBy(type = UploadAdaptor.class, args = { "ioc:myUpload" })
public String fileUpLoad(@Param("file") File file,
@Param("fileName") String fileName,
@Param("fileSize") Integer fileSize,
@Param("fileType") String fileType,
@Param("fileFrom") String fileFrom,
@Param("objectid") Integer objectid) {
JSONObject res = new JSONObject();
try{
String dataStr = commonService.fileUpLoad(file,fileName,fileSize,fileType,fileFrom,objectid);
res.put("success", true);
res.put("data", dataStr);
res.put("message", "上传文件成功");
}catch (Exception e){
e.printStackTrace();
res.put("success", false);
res.put("message", e.toString());
}
return res.toString();
}
状况详细描述如下
查看前端network 发现表单webuploader提交的请求没有 request data 而是request payload,
比较奇怪 不知道是前端的问题还是后台配置的问题