做ocupload上传excel文件的时候 由于用的是springmvc 不知道到返回结果该怎样写 突然想到了jsonWrapper
详见
@RequestMapping("importBatch.htm")
public @ResponseBody
JsonWrapper<Result> importBatch(MultipartFile file) {
JsonWrapper<Result> jsonWrapper = new JsonWrapper<Result>();
Result result = businessBrandService.importBatch(file);
jsonWrapper.setFlag(true);
jsonWrapper.setData(result);
return jsonWrapper;
}
js可以这样写
$(function(){
$('#importBusiness').upload({
name: 'file', // 上传文件项 name属性
enctype:'multipart/form-data', // 编码方式
action : '${contextPath}/back/business/brand/importBatch.htm', // 目标路径
autoSubmit : true, // 自动提交
params : {}, // 其它参数
onComplete : function(response){
var result = eval("("+response+")");
var data =result.data;
var flag=data.success;
if(flag){
alert("上传成功");
}else{
alert("上传失败")
}
}
});