通过Spring ResponseEntity转发

问题描述

使用Spring Boot(2.3.1)Rest Controller。而且我必须转发到外部URL。

在这里找到了一些解决方案:Spring ResponseEntity and forward。并尝试:

  @GetMapping
  public ResponseEntity<Resource> getHtmlReport() {
  //.....some code here
  HttpHeaders headers = new HttpHeaders();
  headers.setLocation(URI.create(url));
  return new ResponseEntity<>(headers,HttpStatus.MOVED_PERMANENTLY);
}

但这不是转发-它是重定向

那么如何使用Spring ResponseEntity进行转发

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)