Java 怎么从servlet获取异步Content

2019年8月17日22:05:01Java 怎么从servlet获取异步Content已关闭评论 177 492字阅读1分38秒

1.简介

Java 怎么从servlet获取异步Content?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */

import javax.servlet.AsyncContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class Main{
    public static AsyncContext getAsyncContext(ServletRequest request,
            ServletResponse response) {
        AsyncContext asyncContext = null;
        if (request.isAsyncStarted()) {
            asyncContext = request.getAsyncContext();
        } else {
            asyncContext = request.startAsync(request, response);
            asyncContext.setTimeout(20000);
        }
        return asyncContext;
    }
}

 
编程十万个怎么办