【发布时间】:2018-03-23 22:21:12
【问题描述】:
如何从同一应用程序的POST 端点调用GET 端点?并使用GET 端点的结果代替POST 请求的正文。
【问题讨论】:
-
你问的是 Mule 还是 Spring-Boot?
标签: java spring-boot mule
如何从同一应用程序的POST 端点调用GET 端点?并使用GET 端点的结果代替POST 请求的正文。
【问题讨论】:
标签: java spring-boot mule
在您的 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
}
然后使用端点返回的任何内容进行处理。
【讨论】: