Question(提问)
Steps to reproduce(问题复现步骤)
Screenshot or Gif(截图或动态图)
刷新后
也就是后台是成功是但是 前台报错 我也不到后台返回这些信息代码对不对
@responsebody
@RequestMapping("upload")
public Map<Object,String> upload(@RequestParam MultipartFile avatar, Long userId, HttpSession session) {
String workplace = System.getProperty("user.dir");
String suffix = avatar.getOriginalFilename().substring(avatar.getOriginalFilename().indexOf("."));
String fileName = "icon" + String.valueOf(userId) + suffix;
File newFile = new File(workplace + "/src/main/resources/static/uimages/" + fileName);
userService.updateUserIcon("/user/getIcon/" + fileName,userId);
Map<Object,String> map = new HashMap<>();
try {
avatar.transferTo(newFile);
System.out.println("success");
Object res = " http://localhost:8081/user/getIcon/icon " + userId + suffix;
String res1 = "/user/getIcon/icon" + userId + suffix;
System.out.println(res);
// map.put("status","success");
map.put("url",res1);
return map;
// return MsgResponse.success("上传成功了啊", res);
} catch (IOException e) {
e.printStackTrace();
// return MsgResponse.fail("上传失败");
return null;
}
}
1条答案
按热度按时间icnyk63a1#
已解决 需要返回状态码code: 20000