IllegalStateException: Not supported on AsyncContext.startAsync(req, res)

后端 未结 2 1414
别那么骄傲
别那么骄傲 2020-12-10 03:34

I have created a servlet 3.0 to explore asynchronous request processing:

@WebServlet(name=\"MyTest\", urlPatterns={\"/MyTest\"}, asyncSupported=true)
public          


        
2条回答
  •  时光取名叫无心
    2020-12-10 04:37

    I checked out Tomcat's code and saw that the asyncSupported variable has to be explicitly set to true. That's why you are getting req.isAsyncSupported() == false.

    You could try to set the async attribute in the HttpServletRequest object to true by one of the following methods.

    req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true);
    

    or

    ((org.apache.catalina.connector.Request)req).setAsyncSupported(true);
    

    Hope it helps.

提交回复
热议问题