为了账号安全,请及时绑定邮箱和手机立即绑定

提交表单之后报空指针异常?

提交表单之后报空指针异常?

慕数据017433 2018-12-29 17:57:09
@Transactional(rollbackFor = Exception.class) public boolean addAccount(User account) {     //密码加盐MD5     account.setPasswd(HashUtils.encryPassword(account.getPasswd()));     //头像保存到本地     List<String> imageList = fileService.getImagePath(Lists.newArrayList(account.getAvatorFile()));     if (!imageList.isEmpty()){      account.setAvator(imageList.get(0));//将相对路径设置进去     }     BeanHelper.setDefaultProp(account,User.class);     BeanHelper.onInsert(account);     userMapper.insert(account);     account.setEnable(0);     mailService.registerNotify(account.getEmail());     return true; } file:   path: D:/pic@Value("${file.path:}") private String filePath; /**  * 将上传文件返回一个列表路径,因为我们存储到数据库里面知识一个路径,不是一个文件,我们的文件是要保存到本地的  */ public List<String> getImagePath(List<MultipartFile> files){     List<String> paths = Lists.newArrayList();     //对每个上传的每个文件进行操作     files.forEach(file -> {         File localFile = null;         if (!file.isEmpty()){             try {             localFile = saveToLocal(file,filePath);             String path = StringUtils.substringAfterLast(localFile.getAbsolutePath(),filePath);             paths.add(path);             }catch(IOException e){                 throw new IllegalArgumentException(e);             }         }     });     return paths; } 2018-12-29 17:55:52.617  INFO 12720 --- [ qtp98801744-35] com.yxs.house.web.filter.LogFilter       :  request---coming...2018-12-29 17:55:52.743 ERROR 12720 --- [ qtp98801744-35] c.yxs.house.web.controller.ErrorHandler  :   nulljava.lang.NullPointerException: null at com.yxs.house.biz.service.FileService.lambda$getImagePath$0(FileService.java:31) ~[classes/:na]    at com.yxs.house.biz.service.FileService$$Lambda$17/1558917749.accept(Unknown Source) ~[na:na] at java.util.ArrayList.forEach(ArrayList.java:1249)     ~[na:1.8.0_25] at com.yxs.house.biz.service.FileService.getImagePath(FileService.java:29) ~[classes/:na]    at com.yxs.house.biz.service.UserService.addAccount(UserService.java:56) ~[classes/:na]
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 1229 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信