【发布时间】:2020-12-27 05:27:18
【问题描述】:
我有以下终点:
@PutMapping(path = "/like/{id}")
public void likeQuestion(@PathVariable("id") String id, @Valid @NotNull @RequestBody Student student) {
logger.info(id, student);
questionService.likeQuestion(id, student);
}
当我尝试从 Angular 前端发送请求时,这不起作用:
likeQuestion(id: string, student: Student) {
console.log(id, student);
return this.http.put(
environment.baseUrl + '/api/questions/like/' + id,
student
);
}
控制台仍会注销id 和student,但是,端点不会被记录。
我在同一个文件中有另一个端点可以工作:
@PutMapping(path = "/edit-comment/{id}")
public void editComment(@PathVariable("id") String id, @Valid @NotNull @RequestBody Comment comment) {
logger.info("Editing comment");
questionService.editComment(id, comment);
}
这里可能存在什么潜在问题?谢谢你。控制器的请求映射为@RequestMapping("api/questions"),与前端请求uri匹配,所以我不知道可能是什么问题。
我尝试在开发工具中检查网络选项卡,但找不到正在发出的任何请求...
【问题讨论】:
-
接收到的http状态码是什么?
-
它甚至没有显示在开发工具中,我该如何检查?
-
后端有什么错误..?
-
我什至看不到,前端没有调用端点...
标签: angular spring-boot