public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView mav = null;
UploadResult uploadResult = new UploadResult();
uploadResult.setResult(1);
FormRequest formrequest = new FormRequest(request);
request.setAttribute("form_upload", formrequest);
if(formrequest.getItem("customerId")!=null){
int customerId = WebUtil.parameter2int(formrequest.getItem("customerId").getValue());
Customer customer = customerService.getById(customerId);
if(customer!=null){
FormRequestItem imgFile = formrequest.getItem("img")!=null?formrequest.getItem("img"):null;
String newFilename = "";
try{
newFilename = FileResources.saveFile(formrequest, imgFile, fileUploadImgPath+customer.getId()+"/");
}
catch(Exception e){
logger.error(e.getMessage());
uploadResult.setResult(0);
}
uploadResult.setFilename(newFilename);
}
else
uploadResult.setResult(0);
}
else{
uploadResult.setResult(0);
}
response.addHeader(Constants.CORS_HEADER, "*");
WebUtil.respons2Json(response, uploadResult);