前端:
{type : "upload", mode : "html4", name : "importFile", inputWidth : 300, url : "/base/baseSkuProp/import"}
fileForm.attachEvent("onUploadComplete", function() {
alert("导入成功");
});
fileForm.attachEvent("onUploadFail", function(fileName, extra) {
alert(extra.msg);
});
后端:
@RequestMapping("/import")
public String importExcel(MultipartFile file) {
try {
//处理file...
return "{state : true, name : '" + file.getOriginalFilename() + "', size : " + file.getSize() + "}";
} catch (Exception e) {
e.printStackTrace();
return "{state : 'fail', extra : {msg : '" + e.getMessage() + "'}}";
}
}