@ResponseBody
public Object upload(MultipartFile file) {
String filename = file.getOriginalFilename();
String uuid = UUID.randomUUID().toString();
//上传的方法在Service层写的,这里直接调用的
boolean boole = pService.savefile(file, uuid);
if (boole) {
Map<String,Object> map = new HashMap<String,Object>();
Map<String,Object> map2 = new HashMap<String,Object>();
map.put(“code”, 0); //0表示上传成功
map.put(“msg”,“上传成功”); //提示消息
//src返回图片上传成功后的下载路径,这里直接给绝对路径
map2.put(“src”, “http://localhost/layUITextarea/download?uuid=”+uuid);
map2.put(“title”, filename);
map.put(“data”, map2);
return map;
} else {
return new AjaxResult(true, file.getOriginalFilename());
}
}
//下载方法
@RequestMapping(value = “/download”)
@ResponseBody
private v