• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

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

@Transactional(rollbackFor = Exception.class)public boolean addAccount(User account) {    //密码加盐MD5    account.setPasswd(HashUtils.encryPassword(account.getPasswd()));    //头像保存到本地    List 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 getImagePath(List files){    List 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]

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

发新帖

发布任务需求已有1031167位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!