前端代码
var url= '<%=path%>/analyzeAssetExcel';
url=url+'?siteId='+siteId;
$.ajaxFileUpload({
url:url,
secureuri:false,
fileElementId:'assetupload',
dataType:'text',
success: function (data, status){
data=$.parseJSON(data);
if(data.result){
$("#impuuid").val(data.uuid);
$("#taskfrmlist").submit();
}else{
alert("数据异常,请检查后重试!");
}
},
error: function (data, status){
alert("上传失败,请重试!");
}
});
后台代码
@RequestMapping(value = "/analyzeAssetExcel")
public String analyzeAssetExcel(@RequestParam(value = "upload") MultipartFile upload, String siteId, HttpServletRequest request, HttpServletResponse response) throws IOException {
boolean result = false;
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
/*******上传附件操作*****/
uuid = result ? uuid : "";
String json = "{\"result\":" + result + ",\"uuid\":\"" + uuid + "\"}";
ajaxOutPutHtml(response, json);
return null;
}
public void ajaxOutPutHtml(HttpServletResponse response,Object obj) throws IOException{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println(obj);
}
ajaxFileUpload上传附件
猜你喜欢
转载自awen7916.iteye.com/blog/2199856
今日推荐
周排行