【问题标题】:Using spring boot, how to ignore the body of a POST request and use the response of a GET endpoint instead使用spring boot,如何忽略POST请求的主体并使用GET端点的响应
【发布时间】:2018-03-23 22:21:12
【问题描述】:

如何从同一应用程序的POST 端点调用GET 端点?并使用GET 端点的结果代替POST 请求的正文。

【问题讨论】:

  • 你问的是 Mule 还是 Spring-Boot?

标签: java spring-boot mule


【解决方案1】:

在您的 POST 端点中,您可以这样调用另一个端点:

@RequestMapping("value = "/yourPostEndpoint", method = RequestMethod.POST)
public void postThis(HttpServletRequest request) {
    String url = request.getRequestURL().toString();
    String relativeGETUrl = url+"/yourGetEndpoint"; 
    String getEndpointResponse = new RestTemplate().getForObject(relativeGETUrl, String.class);

    // Do whatever you want to do with the get response

}

然后使用端点返回的任何内容进行处理。

【讨论】:

    猜你喜欢
    • 2020-09-30
    • 2020-07-29
    • 1970-01-01
    • 2019-07-12
    • 1970-01-01
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    • 2021-02-13
    相关资源
    最近更新 更多