接口 StreamingResponseBody

函数接口:
这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

@FunctionalInterface public interface StreamingResponseBody
A controller method return value type for asynchronous request processing where the application can write directly to the response OutputStream without holding up the Servlet container thread.

Note: when using this option it is highly recommended to configure explicitly the TaskExecutor used in Web MVC for executing asynchronous requests. Both the MVC Java config and the MVC namespaces provide options to configure asynchronous handling. If not using those, an application can set the taskExecutor property of RequestMappingHandlerAdapter.

从以下版本开始:
4.0 2022/4/9 12:07
作者:
Rossen Stoyanchev, Harry Yang
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    writeTo(OutputStream outputStream)
    A callback for writing to the response body.
  • 方法详细资料

    • writeTo

      void writeTo(OutputStream outputStream) throws IOException
      A callback for writing to the response body.
      参数:
      outputStream - the stream for the response body
      抛出:
      IOException - an exception while writing