为了账号安全,请及时绑定邮箱和手机立即绑定

失败:缺少必需的请求正文:public springframework.http.

失败:缺少必需的请求正文:public springframework.http.

米琪卡哇伊 2024-01-25 23:02:05
我已经从 Web 创建了基于应用程序的示例:Angular 中的前端和 Spring Boot 的后端(mer 客户) Angular URL:http://localhost:4200/ Spring Boot URL:http://localhost:9020/(REST:http:// /本地主机:9020/api/ )<h1>Angular Part </h1>`export class Customer {    id: number;    firstname: number;    lastname: Number;    age: number;    active: boolean;}`和import { Customer } from './customer';    export class CustomerService {      private baseUrl = http://localhost:9020/api';      constructor(private http: HttpClient) { }     getCustomer(id: number): Observable<Object> {        return this.http.get(${this.baseUrl}+`/customers`+/${id});}      createCustomer(customer: Customer): Observable<Object> {        console.log("customer.lastname: "+customer.lastname);        console.log("customer.firstname: "+customer.firstname);        return this.http.post(${this.baseUrl} + `/create`, customer);      }      getCustomersList(): Observable<any> {        return this.http.get(${this.baseUrl}+`/customers`);      }    }    import { Component, OnInit } from '@angular/core';    import { Customer } from '../customer';    import { CustomerService } from '../customer.service';`    @Component({      selector: 'create-customer',      templateUrl: './create-customer.component.html',      styleUrls: ['./create-customer.component.css']    })    export class CreateCustomerComponent implements OnInit {      customer: Customer = new Customer();      submitted = false;      constructor(private customerService: CustomerService) { }      ngOnInit() {      }      newCustomer(): void {        this.submitted = false;        this.customer = new Customer();      }      save() {        this.customerService.createCustomer(this.customer)          .subscribe(data => {console.log(data);            this.submitted = true;},error => console.log(error));            this.customer = new Customer();}      onSubmit() {           this.save();}}
查看完整描述

1 回答

?
牧羊人nacy

TA贡献1862条经验 获得超7个赞

在Entity类中,该列名为“first_name”,但是当您创建表时,它以“firstname”命名,下划线消失了。



查看完整回答
反对 回复 2024-01-25
  • 1 回答
  • 0 关注
  • 29 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信