gpt4 book ai didi

java - Angular 8删除方法不调用Spring Boot删除方法

转载 作者:行者123 更新时间:2023-12-01 17:35:04 25 4
gpt4 key购买 nike

我的 Angular 8 删除方法没有调用 Spring Boot 删除方法(日志中没有打印任何内容)

Angular 8删除方法:

deleteStudent(id: number): Observable<any> {
console.log(`${this.baseUrl}/deleteById/${id}`);
return this.httpClient.delete(`${this.baseUrl}/deleteById/${id}`, { responseType: 'text' });
}

Spring Boot删除方法(REST API):

@DeleteMapping("/deleteById/{id}")
@ResponseBody
ResponseEntity<?> deleteById(@PathVariable("id") long id){
try{
studentService.deleteById(id);
LOGGER.info("record successfully deleted");
return new ResponseEntity<>(HttpStatus.OK);
}catch (Exception e){

return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}

打印 Angular 网址后,例如: http://localhost:8888/deleteById/55 在控制台中我复制了它并在 postman 中使用,特定记录已成功删除。此问题仅出现在删除方法中,其他方法完全有效。

最佳答案

这是我的错误,我没有订阅服务类中的删除方法。

关于java - Angular 8删除方法不调用Spring Boot删除方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61056377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com