manage/product/upload.do方法中MultipartFile file中的file 报空指针
来源:8-9 商品管理模块所有功能自测
夏目喵
2017-09-13
@RequestMapping("upload.do")
@ResponseBody
public ServerResponse upload(HttpSession session, HttpServletRequest request, MultipartFile file){
User user = (User) session.getAttribute(Const.CURRENT_USER);
if (user == null ){
return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录");
}
if (iUserService.checkAdminRole(user).isSuccess()){
//业务逻辑
String path = request.getSession().getServletContext().getRealPath("upload");
String targetFileName = iFileService.upload(file,path);
String url = PropertiesUtil.getProperty("ftp.server.http.prefix")+targetFileName;
Map fileMap = Maps.newHashMap();
fileMap.put("uri",targetFileName);
fileMap.put("url",url);
return ServerResponse.createBySuccess(fileMap);
}else{
return ServerResponse.createByErrorMessage("无权限操作");
}
}写回答
4回答
-
Tsien
2019-04-20
请问是怎么解决的,我也一直报这个错
00 -
Geely
2017-09-14
我给大家整理了这个,有问题可以来看看先找一下。 肯定有你想要的哈
部署环境的话 ,建议看下文章最后一小段哟~
http://www.imooc.com/article/20193
课程求10分好评哇谢谢啦~~(づ ̄ 3 ̄)づ
00 -
Geely
2017-09-14
赞,已解决就好。
00 -
夏目喵
提问者
2017-09-13
已解决
00
相似问题