weixin_43429839
聆听你的心
采纳率38.5%
2019-09-19 09:37 阅读 1.3k

org.apache.ibatis.binding.BindingException: Mapper method 'com.easy.demo.mapper.UserMapper.loginUser attempted to return null from a method with a primitive return type (int).报错怎么解决?

@RequestMapping(value = {"/loginUser"},method = RequestMethod.GET)
        public void login(User user, HttpServletRequest request, HttpSession session) throws UnsupportedEncodingException, NoSuchAlgorithmException {
            int i=0;
            String s=user.getPassword();
            String md=HexUtil.getEncryptedPwd(s);
            //对比数据库密码
            user.setPassword(md);
            try {
                i=userMapper.loginUser(user);
            }catch (Exception e){
                e.printStackTrace();
            }
            System.out.println(i);
            if (i==1){
                System.out.println("账号或密码输入错误");
            }else {
                System.out.println("登陆成功");
            }
        }

userMapper里的loginUser定义是:int loginUser(User user);
userService里的loginUser:void loginUser(User user);
userServiceImpl里的loginUser:@Override
public void addUser(User user) {

    userMapper.addUser(user);
}

不论密码的对错,运行报错输出的i值始终为0,谁能帮我看看怎么解决

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • JonathanYan JonathanYan 2019-09-19 10:06

    org.apache.ibatis.binding.BindingException:
    Mapper method

    'com.easy.demo.mapper.UserMapper.loginUser 这指的是i=userMapper.loginUser(user)的loginUser
    attempted to return null 这个函数返回了null
    from a method with a primitive return type (int).但是应当返回int

    点赞 1 评论 复制链接分享
  • doncha doncha 2019-09-19 09:51

    你userMapper里的loginUser是怎么写的啊,返回的结果是什么

    点赞 评论 复制链接分享

相关推荐