当前位置:   article > 正文

JSON parse error: Cannot deserialize value of type `java.lang.Integer` from Boolean value

json parse error: cannot deserialize value of type `java.lang.integer` from

问题原因所在:前端Vue传输的数据字段类型和后端实体类字段不一致。
我的实体类字段是int类型。前端传输的数据是布尔类型

1、后端方法

    @RequestMapping(value = "/car/editCar", method = RequestMethod.PUT)
    public Result updateOneUser(@RequestBody Car car) {
        int rs = carService.updateCar(car);
        if (rs > 0) {
            return Result.ok();
        } else {
            throw new BusinessException(ResultCode.UPDATE_USER_ERROR.getCode(),
                    ResultCode.UPDATE_USER_ERROR.getMessage());
        }

    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

2、实体类字段

在这里插入图片描述

报错信息

2、前端传输的数据

在这里插入图片描述

            <el-button type="primary" @click="editCar(scope.$index,scope.row)" icon="el-icon-edit" circle>编辑</el-button>

  • 1
  • 2

调用方法打开窗口的方法,将数据写入弹窗中

     editCar(index, row) {
        this.dialogVisible = true;//dialog对话窗口打开
        this.editForm = Object.assign({}, row);//将数据传入dialog页面
        this.editForm.index=index;//传递当前index

      },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

点击弹窗form表单的提交按钮

    <el-button type="primary" @click="update('editForm')">确 定</el-button>

  • 1
  • 2

再次调用方法

      update(formName) {
        const _this = this;
        this.editForm.status=0  //直接设置值,
        console.log(this.editForm)
        this.$refs[formName].validate((valid) => {
          if (valid) {
            axios.put('/car/editCar',this.editForm).then(function (resp) {
              if(resp.data.code==200){
                _this.$alert('修改成功', '消息', {
                  confirmButtonText: '确定',
                  callback: action => {
                    _this.dialogVisible = false;//dialog对话窗口关闭
                    _this.showAllUsers();
                  }
                });

              }
            })
          }
        });
      },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/520509
推荐阅读
相关标签
  

闽ICP备14008679号