【发布时间】:2022-01-23 17:53:43
【问题描述】:
第一个请求有效,但第二个请求给出 404,找不到路径 它可以用来做什么?
@PostMapping(value = "/postsViews", consumes = "application/json", produces = "application/json")
public Integer generateViews(@RequestBody PostViewsDTO requestDTO) throws IOException, JRException {
viewsService.generate(requestDTO.getFileName(), requestDTO.getProjectId());
return HttpServletResponse.SC_OK;
}
@PostMapping(value = "/favorite", consumes = "application/json", produces = "application/json")
public Integer generateFavorite(@RequestBody FavoriteDTO requestDTO) throws IOException, JRException {
favoriteService.generate(requestDTO);
return HttpServletResponse.SC_OK;
}
【问题讨论】:
-
你点击了什么网址?找不到 URL 时发生 404 错误。
-
host.ru/favorite 404 找不到路径/收藏夹。同时/postsViews也在同一个控制器中,效果很好
-
( @RestController @RequestMapping("/rep") ) POST localhost:8080/rep/favorite 响应:“时间戳”:“2021-12-22T14:18:04.193+0000”,“状态”:404, “错误”:“未找到”,“消息”:“”,“路径”:“/rep/favorite”
-
还添加第一个给你结果的请求
-
您应该将其添加到描述中,并提供有助于重现的最少代码...
标签: spring spring-boot