首页 > 解决方案 > Spring Restcontroller - 检查客户端是否断开连接

问题描述

是否有可能检查 Spring RestController,客户端是否关闭了连接?

我尝试实现这样的事情:

@GetMapping
public ResponseEntity<Resource> createZipFile(@PathVariable String id) {

  // ...

  for (Task task : tasks) {
    boolean connectionBroken = // ???
      if (connectionBroken) {
        // exit!
      }
    // execute task which might take a bit time... 
  }

  // Return result...
}

标签: connectionspring-restcontroller

解决方案


推荐阅读