【问题标题】:Not working @PostMapping 404 path not found不工作@PostMapping 404 找不到路径
【发布时间】: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


【解决方案1】:

我能想到的只有两件事。

首先,为确保您运行的是您认为的代码,请尝试关闭应用程序,然后“清理”项目,再次构建并运行它。

如果这不起作用,则可能是您发布的数据与 FavoriteDTO 的定义不匹配。尝试注释掉参数和使用它的代码行。

【讨论】:

    【解决方案2】:

    问题解决了,gitlab上传的不是服务器最后一次提交

    【讨论】:

      猜你喜欢
      • 2022-06-13
      • 1970-01-01
      • 2021-04-25
      • 2019-06-10
      • 2015-07-26
      • 1970-01-01
      • 2014-12-27
      • 1970-01-01
      • 2019-02-02
      相关资源
      最近更新 更多