Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从REST服务器返回数据之前检查REST连接_Java_Spring_Rest_Http - Fatal编程技术网

Java 从REST服务器返回数据之前检查REST连接

Java 从REST服务器返回数据之前检查REST连接,java,spring,rest,http,Java,Spring,Rest,Http,我使用Spring框架创建RESTHTTP服务器 @RestController @RequestMapping("/message") public class MessageRequest { @RequestMapping(method = RequestMethod.POST) public @ResponseBody String doPost( @PathVariable String param ) { /*do somet

我使用Spring框架创建RESTHTTP服务器

@RestController
@RequestMapping("/message")
public class MessageRequest {

    @RequestMapping(method = RequestMethod.POST)
    public @ResponseBody String doPost(
        @PathVariable String param
    ) {
        /*do something */
        return "answer";
    }
}

在向客户端发送响应之前,我需要检查连接。若客户端断开连接(例如读取超时),那个么应答将通过另一种方式发送。在返回响应之前,我如何检查连接?

这听起来不像REST。REST是幂等的-不了解客户端。我认为HTTP在这方面帮不了你。你考虑过WebSocket吗?HTTP的可能副本不是一个面向连接的协议。对我来说,这听起来不像REST。REST是幂等的-不了解客户端。我认为HTTP在这方面帮不了你。您考虑过WebSocket吗?HTTP的可能副本不是面向连接的协议。