【发布时间】:2018-04-18 04:40:08
【问题描述】:
尝试执行 PUT 方法时出现错误。错误是这样的:
PUT http://localhost:3000/Student/ 404 (Not Found)
这是来自 stock.service.ts 文件的 sn-p
updStudent(id: string, newName: string, newYear: string, newSemester: string, newScore: string): Observable<any>
{
console.log(JSON.stringify({
name: newName,
year: newYear,
semester: newSemester,
score: newScore
}));
return this.http.put("http://localhost:3000/Student/", +id,
JSON.stringify({
name: newName,
year : newYear,
semester : newSemester,
score: newScore
}));
}
这是来自 app.component.ts 文件的 sn-p
selectedStudent: any;
updStudent(Id: string, newName: string, newYear: string, newSemester: string, newScore: string)
{
this.stockService.updStudent(this.selectedStudent.Id, newName, newYear, newSemester, newScore).subscribe(
data =>
{
this.getAllStocks();
}
);
console.log('here', Id , newName, newYear, newSemester, newScore);
}
谁能帮我解决这个错误?如果需要更多的 sn-ps,请告诉我。谢谢。
【问题讨论】:
-
你能把
http;//localhost:3000/Student/改成http://localhost:3000/Student/吗? (注意;和:) -
localhost:4200 来自哪里?
-
我也不知道 localhost:4200 是从哪里来的
-
将
;更改为: -
那么...它有效吗?
标签: javascript json angular html-table put