Angular提交数据为空

submitForm(value: {

    id: number; account: string;

    realName: string;

    sex: string;

    email: string;

    phoneNum: number;

    telephoneNum: number;

    isAdmin: string;

    status: string;

    address: string;

    birthday: number;

  }): void {

    // tslint:disable-next-line:forin

    for (const key in this.validateForm.controls) {

      this.validateForm.controls[key].markAsDirty();

      this.validateForm.controls[key].updateValueAndValidity();

    }

    console.log(value);

    this.userService.save(value).subscribe(res => {

      console.log(res)

      this.nzMessageService.create('success', '添加员工成功')

      this.router.navigate(['/home/user'])

    })

  }

此为提交数据方法,控制台打印为空

image

http请求的代码呢,谜语人?

// 添加员工

save(params: User) {

return this.http.post(`${URL}/user/save`, params)

}

@PostMapping("/save")
public void save(@RequestBody User user){
userService.save(user);
}

后端加了 @RequstBody 报了 400错误

日期类型如何传值

那你到底是post不到后端还是后端返回的resp是null还是400错误,到底是哪个问题

现在是 400

Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '0' could not be parsed at index 0

不要用LocalDateTime来接参数。。。。springboot本身是不支持的,用Date,除非你自己写了序列化bean

1 个赞

噢噢 好的