zoukankan      html  css  js  c++  java
  • 报错:For input string: ""

    报错具体内容如下:

     原因分析:输入空字符串,无法解析成长整形

    错误代码:

    前端

    openEditDialog(dialogStatus, titleStatus, row) {
          this.dialogTableVisible = dialogStatus;
          this.titleStatus = titleStatus;
          if (titleStatus === "create") {
            this.cleanData();
          }
          if (row) {
            this.entity = Object.assign({
              goodsCode: "",
              goodsName: "",
              goodsType: "",
              goodsSpec: "",
              packageType: "",
              goodsEngName: "",
              produceAddress: "",
              isvalid: "1",
              goodsDesc: "",
              remark: "",
              entityId: ""
            }, row);
            this.oldGoodsCode=this.entity.goodsCode;
          }
          this.$nextTick(() => {
            this.$refs["form"].clearValidate();
          })
    
        },
    cleanData() {
    this.entity = {
    goodsCode: "",
    goodsName: "",
    goodsType: "",
    goodsSpec: "",
    packageType: "",
    goodsEngName: "",
    produceAddress: "",
    isvalid: "1",
    goodsDesc: "",
    remark: "",
    entityId: ""
    }
    this.enpriseName = "";
    },
    create() {
    this.$refs['form'].validate((valid) => {
    if (valid) {
    this.submitLoading = true;
    saveGoods(this.entity).then(res => {
    if(res.success){
    this.$message.success(res.msg);
    this.$emit("getList")
    }else {
    this.$message.error(res.msg);
    }
    }).catch(() => {
    this.$message.error("新增失败")
    }).finally(() => {
    this.submitLoading = false;
    this.close();
    })
    }
    })
    },

    后台:

    @PostMapping("/saveGoods")
        @Log("添加商品")
        public Result saveGoods(@RequestBody Goods goods) throws Exception {
            return goodsService.saveGoods(goods);
    
        }

    Goods实体类中

    /**
         * 所属企业
         */
        @Column(name="entity_id")
        @JsonSerialize(using = LongJsonSerializer.class)
        @JsonDeserialize(using = LongJsonDeserializer.class)
        private Long entityId;

    当点击添加时,由于this.entity.entityId值为空字符串,后台用Long类型的entityId接收,故报错

    解决方案:前端传递entityId时将空字符串改为null。

  • 相关阅读:
    HDU 1572 (DFS)
    UVA 439 BFS 骑士的移动
    STL next_permutation 和 prev_permutation
    Fire Net
    HDU 1026
    Awesome CS Courses 超级棒的课程
    Tensorflow 最佳实践样例程序-mnist
    关于交叉熵在loss函数中使用的理解
    神经网络训练程序,tensorflow
    神经网络前向传播算法的tensorflow实现。
  • 原文地址:https://www.cnblogs.com/zwh0910/p/15467536.html
Copyright © 2011-2022 走看看